/*
* Bitmapfonts.java
*
* Created on 07. April 2009, 17:00
*.
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
//package bitmapfonts;
//import java.awt.image.ImageObserver;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.event.*;
//import java.awt.image.BufferedImage;
//import javax.imageio.ImageIO;
//import java.lang.*;
//import java.lang.NullPointerException;
///import java.applet.*;
//import java.awt.*;
//import java.awt.event.*;
//implements MouseMotionListener, ActionListener {
/**
*
* @author surfer_xyz
*/
public class BitmapFonts extends java.applet.Applet implements MouseMotionListener
{
/** Initialization method that will be called after the applet is loaded
* into the browser.
*/
Image img; // Bild wird verwaltet über img
Image imgBalkenWaagrecht;
Image imgBalkenSenkrecht;
//Image bufferImg; // wird fuer doublebuffer benötigt
//String scrText = "mehrzeiliger text ist mitAgross a codiert Amoeglich"; // Test String
String scrText = "amigaAAlinuxAAtutorialsAAprogrammeAAsprachenAAlinksAAdl";
String alleZeichen = " ! '() ,-./0123456789:; ? abcdefghijklmnopqrstuvwxyz"; // Zeichenfolge des "autofont.gif"
Integer strLaenge; // hält die länge des srcText fest
Character einzelnesZeichen = 0;
int fontBreite = 16;
int fontHoehe = 16;
int iStandartWertAnfangX = 20;
int iStandartWertAnfangY = 120;
int iAnfangX = iStandartWertAnfangX;
int iAnfangY = iStandartWertAnfangY;
int iZ = 0;
Integer positionImString = 0;
Integer alleZeichenReihe = 0;
int iZeile = 0;
int iSpalte = 0;
public KOORDINATEN [] koord;
public void init() {
// TODO start asynchronous download of heavy reso
img = getImage(getCodeBase(), "10-lang_neu.gif");
imgBalkenSenkrecht = getImage(getCodeBase(), "balken_senkrecht.GIF" );
imgBalkenWaagrecht = getImage(getCodeBase(), "balken_waagrecht.gif" );
strLaenge = scrText.length();
koord = new KOORDINATEN[strLaenge];
for(iZ=0; iZ<strLaenge; iZ++)
{
koord[iZ]= new KOORDINATEN();
}
setBackground(Color.BLACK);
}
public void start()
{
for(iZ=0; iZ < strLaenge; iZ++)
{
try{
einzelnesZeichen = scrText.charAt(iZ);
positionImString = alleZeichen.indexOf(einzelnesZeichen);
if(positionImString == 0)
{
positionImString = 3;
}
koord[iZ].sx1 = fontBreite * positionImString + fontBreite;
koord[iZ].sx2 = fontBreite * positionImString + fontBreite + fontBreite;
koord[iZ].sy1 = 0;
koord[iZ].sy2 = fontHoehe;
if(einzelnesZeichen == 'A')
{
iZeile = -1;
iAnfangX = iStandartWertAnfangX;
iAnfangY = iAnfangY + fontHoehe;
}
koord[iZ].dx1 = iAnfangX + iZeile * fontBreite;
koord[iZ].dx2 = iAnfangX + iZeile * fontBreite + fontBreite;
koord[iZ].dy1 = iAnfangY ;
koord[iZ].dy2 = iAnfangY + fontHoehe;
iZeile = iZeile +1;
}
catch (Exception e)
{
break;
}
}
}
public void mouseDragged (MouseEvent e){}
public void mouseMoved (MouseEvent e)
{
if(e.getX() > 0 && e.getY() > 120 &&
e.getX() < 16 && e.getY() < + 160)
{
repaint();
}
else
{
repaint();
}
}
public void paint(Graphics g)
{
int iZaehler = 0;
int strLaenge = 0;
strLaenge = scrText.length();
for(iZaehler = 0; iZaehler < strLaenge; iZaehler++)
{
try
{
g.drawImage(img, koord[iZaehler].dx1, koord[iZaehler].dy1, koord[iZaehler].dx2, koord[iZaehler].dy2,
koord[iZaehler].sx1, koord[iZaehler].sy1, koord[iZaehler].sx2, koord[iZaehler].sy2, this);
//zg.drawString(positionImString.toString(), 100, 100);
}
catch(Exception e)
{
break;
}
g.drawImage(imgBalkenWaagrecht, 0, 80, this);
g.drawImage(imgBalkenWaagrecht, 0, 0, this);
g.drawImage(imgBalkenWaagrecht, 0, 479, this);
g.drawImage(imgBalkenSenkrecht, 180, 0, this);
g.drawImage(imgBalkenSenkrecht, 639, 0, this);
g.drawImage(imgBalkenSenkrecht, 0, 0, this);
}
}
public void stop()
{
}
public void destroy()
{
}
public void mouseClicked (MouseEvent e){}
public void mouseEntered (MouseEvent e){}
public void mouseExited (MouseEvent e){}
public void mousePressed (MouseEvent e){}
public void mouseReleased (MouseEvent e){}
// TODO overwrite start(), stop() and destroy() methods
}