1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
| /**
* Paints the component in the specified graphic context
* (draws the image, at the position and with the size definined
* in this component properties)
* @param g the graphic context in which the part has to be paint
*/
public void paint(Graphics g) {
if (getImage() != null) { // a security, but a Part is supposed to own an image!
// the image drawing itself
// if it is not a wire, we display the image, else we paint the wire
// by using the specific method
if (wire == null) {
g.drawImage(getImageToPaint(),
(int) (getPosWidth().intValue() * UtilityManager.zoomvalue),
(int) (getPosHeight().intValue() * UtilityManager.zoomvalue),
(int) (getDefaultWidth().intValue() * UtilityManager.zoomvalue),
(int) (getDefaultHeight().intValue() * UtilityManager.zoomvalue),
this);
} else {
wire.paintWire(this, g);
}
// if "selected" and not "drag Mode", we add a rectangle
// around the image
if (isSelected() && paintSpecialDrag == false) {
//g.setColor(Color.RED);
g.setColor(Color.BLUE);
g.draw3DRect(
(int) (getPosWidth().intValue() * UtilityManager.zoomvalue),
(int) (getPosHeight().intValue() * UtilityManager.zoomvalue),
(int) (getDefaultWidth().intValue()
* UtilityManager.zoomvalue),
(int) (getDefaultHeight().intValue()
* UtilityManager.zoomvalue),
true);
g.setColor(Color.BLACK);
}
}
paintSpecialDrag = false; // the next paint will be a normal one
// (except if called by a drag, of course)
// we put a tool tip with some informations
// especially useful for debug :
setToolTipText(getName() + " posX:" + getPosWidth() + " posY:" +
getPosHeight() + " sizeX:" + getDefaultWidth() + " sizeY:" +
getDefaultHeight());
} |
Partager