|
Im hoping that
someone can give me some insight on the following issue: I am writing a java 2D imaging application that allows the
user to annotate crosses on top of a jpeg image (among allowing other image
manipulations as well). I have been
trying to implement a tooltip for each of the
annotations so that it will display some info about that particular
annotation. To do so, I created a class
called crossAnnotation that extends JComponent, thus allowing me use the setToolTipText
method for each crossAnnotation object. The problem however, is that when I add the crossAnnoation(JComponent) obect to the imageCanvas(JPanel) where the
image is drawn my whole program freezes. The program can’t seem to handle
the crossAnnotation being added to the imageCanvas as JComponent. Anyone know why? or
maybe how I can implement the toolTip in some other
way (but as far as I can se toolTip only works with JComponent)? Any help
would be greatly appreciated. Thanks Dave Here’s my code for crossAnnotation public class CrossAnnotation extends JComponent{ private
GeneralPath p; private
double drawX, drawY; private
double magFactor; private
Graphics2D g2D; private
Spot2GPlate spot; public
CrossAnnotation(double drawX,
double drawY, double magFactor,
Graphics2D g2D, Spot2GPlate spot) { //addMouseListener(this); this.drawX = drawX; this.drawY = drawY; this.magFactor = magFactor; this.g2D =
g2D; this.spot = spot; this.setToolTipText("aupa!!!!"); //makeCross(); } public
void make(int swidth, int sheight, double magFactor, double width, double height){ p = new GeneralPath(GeneralPath.WIND_NON_ZERO); p.moveTo(0,
-sheight); p.lineTo(0,
sheight); p.moveTo(-swidth, 0); p.lineTo(swidth, 0); //this.setSize(swidth*2, sheight*2); } public
void setColorandDraw(int i, SpotList spotList,
int gelType, boolean annotatedCanvas){ if(i < spotList.getNumAnnotated()) { if ((spot.getSpotExpressionTarget()
- spot.getSpotExpressionControl()) > 0) { if(gelType == 1) g2D.setColor(Color.red); else { g2D.setColor(new Color(0,150,0)); } } else { if(gelType == 1) { g2D.setColor(new Color(0,150,0)); } else g2D.setColor(Color.red); } this.drawAnnotation(drawX, drawY); } else { if(spotList.size() > spotList.getNumAnnotated()) { if(annotatedCanvas) g2D.setColor(Color.red); else g2D.setColor(new Color(0,150,0)); this.drawAnnotation(drawX, drawY); } } } public
void setAnnotationLabel(int
canvasH){ //System.out.println("canvasH: "+canvasH); g2D.setColor(Color.blue); Font f = new Font("Dialog", Font.PLAIN,
(int)(12*magFactor)); g2D.setFont(f); //g2D.translate(drawX, drawY); g2D.drawString(spot.getSpotIdentifier(),
(int)(drawX-(15*magFactor)), (int)(drawY-((canvasH/36)*magFactor))); //g2D.dispose(); } public
void drawAnnotation(double drawX,
double drawY){ //g2D.setColor(Color.red); g2D.translate(drawX, drawY); g2D.draw(p); g2D.translate(-drawX, -drawY); //g2D.dispose(); } /*public void mouseClicked(MouseEvent e) { //To change body of implemented methods use File | Settings | File
Templates. } public
void mouseEntered(MouseEvent
e) { System.out.println("mouseEntered"); this.setToolTipText("x: "+drawX+" y:
"+drawY);//To change body of implemented methods
use File | Settings | File Templates. } public
void mouseExited(MouseEvent
e) { //To change body of implemented methods use File | Settings | File
Templates. } public
void mousePressed(MouseEvent
e) { //To change body of implemented methods use File | Settings | File
Templates. } public
void mouseReleased(MouseEvent
e) { //To change body of implemented methods use File | Settings | File
Templates. } */ } |
- [JAVA2D] ToolTipText Braun-Friedman, David
- Re: [JAVA2D] tooltiptext Braun-Friedman, David
- Re: [JAVA2D] tooltiptext Dmitri Trembovetski
