Désormais, tout le monde devrait avoir les objets graphiques qui s'affichent et que l'on peut Drag & Dropper...
Pensez à enlever les caractères insécables que votre Emacs semble ne pas comprendre !
Ajoutez à votre classe jdraw.graphicobjects.TextArea
l'attribut d'instance et la méthode suivants (pour gérer l'alignement du texte et mettre à jour la variable bounding_box
notamment utilisée lors des détections d'objets les plus proches) :
/** The ascent of this text. */
/**
* Updates the size of this bounding box area.
*/
{
g.dispose();
dummy_image.flush();
ascent= line_metrics.getAscent();
bounding_box.width= font_metrics.stringWidth( text );
bounding_box.height= (
bounding_box.x= (( (alignment == SwingConstants.WEST)
|| (alignment == SwingConstants.NORTH_WEST)
|| (alignment == SwingConstants.SOUTH_WEST))
? getX()
: (( (alignment == SwingConstants.EAST)
|| (alignment == SwingConstants.NORTH_EAST)
|| (alignment == SwingConstants.SOUTH_EAST))
? getX() - bounding_box.width
: getX() - bounding_box.width/2));
bounding_box.y= (( (alignment == SwingConstants.NORTH)
|| (alignment == SwingConstants.NORTH_WEST)
|| (alignment == SwingConstants.NORTH_EAST))
? getY()
: (( (alignment == SwingConstants.SOUTH)
|| (alignment == SwingConstants.SOUTH_WEST)
|| (alignment == SwingConstants.SOUTH_EAST))
? getY() - bounding_box.height
: getY() - bounding_box.height/2));
}
Et simplifiez la méthode paint
à :
/**
* Paints this text area.
*/
{
g.setColor( getColor() );
g.setFont( font );
g.drawString( text, bounding_box.x, (
}
Enfin, remplacez votre fichier jdraw/ui/Misc.java
par celui-ci : cela ajoute une méthode statique
buildIconImage
...
jdraw.graphicobjects.GraphicObject
les méthodes suivantes : /**
* Returns a dialog box used to set the properties of this object.
* This dialog box is packed and ready to be set visible.
*/
public GraphicObjectProperties getPropertyDialog( final Frame owner_frame )
{
return new GraphicObjectProperties( owner_frame, this );
}
/**
* Opens a dialog box used to set the properties of this object.
*/
public void openPropertyDialog( final Frame owner_frame )
{
final GraphicObjectProperties object_properties= getPropertyDialog( owner_frame );
object_properties.pack();
Misc.centerWindow( object_properties );
object_properties.setVisible( true );
}
jdraw.ui.GraphicObjectProperties
, dont voici une source de départopenPropertyDialog
soit invoquée lorsque l'on clique avec le bouton droit de la souris près d'un objet graphique. Dernière mise à jour : 02/04/2009 à 23:00 | ![]() |