List of usage examples for org.jfree.chart.annotations XYShapeAnnotation setToolTipText
public void setToolTipText(String text)
From source file:gov.nih.nci.cma.web.graphing.CMAPrincipalComponentAnalysisPlot.java
/** * This chart uses the XYAnnotation as a glyph to represent * a single pca data point. Glyph shape is determined by survival time. * Survival of more than 10 months is represented by a circle. 10 months or less * is represented by a square. Component1 values are represented by X * Component2 values are represented by Y *//*from w w w. j a va 2 s.co m*/ private void createGlyphsAndAddToPlot(XYPlot plot) { //, double glyphScaleFactor) { XYShapeAnnotation glyph; Shape glyphShape = null; Color glyphColor; NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis(); Range r = domainAxis.getRange(); double upperBound = r.getUpperBound(); double dotSize = 0.7; if (upperBound >= 50 && upperBound <= 100) dotSize = 1d; else if (upperBound > 100 && upperBound <= 150) dotSize = 2d; else if (upperBound > 150 && upperBound <= 200) dotSize = 3d; else if (upperBound > 200) dotSize = 5d; //PrincipalComponentAnalysisDataPoint pcaPoint; double x, y; //for (Iterator i=dataPoints.iterator(); i.hasNext(); ) { for (CMAPCADataPoint pcaPoint : dataPoints) { x = pcaPoint.getComponentValue(component1); y = pcaPoint.getComponentValue(component2); String sampleGroupName = pcaPoint.getSampleGroupName(); String order = sampleGroupNames.get(sampleGroupName); glyphShape = getShapeForDataPoint(order, x, y, dotSize); glyphColor = colorMap.get(order); if (glyphColor == null) glyphColor = Color.black; glyph = new XYShapeAnnotation(glyphShape, new BasicStroke(1.0f), Color.BLACK, glyphColor); String tooltip = ""; tooltip = pcaPoint.getSampleId() + " " + pcaPoint.getSampleGroupName(); glyph.setToolTipText(tooltip); plot.addAnnotation(glyph); } }
From source file:gov.nih.nci.caintegrator.ui.graphing.chart.plot.ClinicalPlot.java
private void createGlyphsAndAddToPlot(XYPlot plot) { XYShapeAnnotation glyph; Shape glyphShape;/*w w w . ja v a 2 s. c o m*/ Color glyphColor; ClinicalDataPoint clinicalPoint; String survivalLenStr; double x, y; for (Iterator i = dataPoints.iterator(); i.hasNext();) { clinicalPoint = (ClinicalDataPoint) i.next(); x = clinicalPoint.getFactorValue(factor1); y = clinicalPoint.getFactorValue(factor2); if ((x != ClinicalDataPoint.MISSING_CLINICAL_FACTOR_VALUE) && (y != ClinicalDataPoint.MISSING_CLINICAL_FACTOR_VALUE)) { //Make this a triangle GeneralPath gp = new GeneralPath(); float xf = (float) x; float yf = (float) y; //make a triangle gp.moveTo(xf, yf); gp.lineTo(xf + 1.5f, yf - 1.5f); gp.lineTo(xf - 1.5f, yf - 1.5f); gp.closePath(); glyphShape = gp; //Rectangle2D.Double rect = new Rectangle2D.Double(); //rect.setFrameFromCenter(x,y, x+1,y+1); //glyphShape = rect; glyphColor = getColorForDataPoint(clinicalPoint); glyph = new XYShapeAnnotation(glyphShape, new BasicStroke(1.0f), Color.BLACK, glyphColor); if (clinicalPoint.getSurvivalInMonths() >= 0.0) { survivalLenStr = nf.format(clinicalPoint.getSurvivalInMonths()); } else { survivalLenStr = ""; } String tooltip = clinicalPoint.getPatientId() + " " + clinicalPoint.getDiseaseName() + " survivalMonths=" + survivalLenStr; glyph.setToolTipText(tooltip); plot.addAnnotation(glyph); } } }
From source file:gov.nih.nci.caintegrator.ui.graphing.chart.plot.PrincipalComponentAnalysisPlot.java
/** * This chart uses the XYAnnotation as a glyph to represent * a single pca data point. Glyph shape is determined by survival time. * Survival of more than 10 months is represented by a circle. 10 months or less * is represented by a square. Component1 values are represented by X * Component2 values are represented by Y *///from w w w . j a va2 s . c o m protected void createGlyphsAndAddToPlot(XYPlot plot) { XYShapeAnnotation glyph; Shape glyphShape; Color glyphColor; PrincipalComponentAnalysisDataPoint pcaPoint; double x, y; for (Iterator i = dataPoints.iterator(); i.hasNext();) { pcaPoint = (PrincipalComponentAnalysisDataPoint) i.next(); x = pcaPoint.getComponentValue(component1); y = pcaPoint.getComponentValue(component2); double survival = pcaPoint.getSurvivalInMonths(); if ((survival > 0) && (survival < 10.0)) { Rectangle2D.Double rect = new Rectangle2D.Double(); rect.setFrameFromCenter(x, y, x + 2, y + 2); glyphShape = rect; } else if ((survival > 0) && (survival >= 10.0)) { Ellipse2D.Double circle = new Ellipse2D.Double(); circle.setFrameFromCenter(x, y, x + 2, y + 2); glyphShape = circle; } else { //Rectangle2D.Double rect = new Rectangle2D.Double(); //rect.setFrameFromCenter(x,y, x+2,y+2); GeneralPath gp = new GeneralPath(); float xf = (float) x; float yf = (float) y; //make a triangle gp.moveTo(xf, yf); gp.lineTo(xf + 3.0f, yf - 3.0f); gp.lineTo(xf - 3.0f, yf - 3.0f); gp.closePath(); glyphShape = gp; } glyphColor = getColorForDataPoint(pcaPoint); glyph = new XYShapeAnnotation(glyphShape, new BasicStroke(1.0f), Color.BLACK, glyphColor); String tooltip = ""; if (pcaPoint.getSurvivalInMonths() <= 0.0) { tooltip = pcaPoint.getSampleId() + " " + pcaPoint.getDiseaseName(); } else { tooltip = pcaPoint.getSampleId() + " " + pcaPoint.getDiseaseName() + " survivalMonths=" + nf.format(pcaPoint.getSurvivalInMonths()); } glyph.setToolTipText(tooltip); plot.addAnnotation(glyph); } }
From source file:gov.nih.nci.rembrandt.web.plots.RBTPrincipalComponentAnalysisPlot.java
/** * This chart uses the XYAnnotation as a glyph to represent * a single pca data point. Glyph shape is determined by survival time. * Survival of more than 10 months is represented by a circle. 10 months or less * is represented by a square. Component1 values are represented by X * Component2 values are represented by Y *///from w w w . j a va 2s . com protected void createGlyphsAndAddToPlot(XYPlot plot) { //for RBT, if its non_tumor, show a diamond meaning "N/A for survival" XYShapeAnnotation glyph; Shape glyphShape; Color glyphColor; PrincipalComponentAnalysisDataPoint pcaPoint; double x, y; for (Iterator i = dataPoints.iterator(); i.hasNext();) { pcaPoint = (PrincipalComponentAnalysisDataPoint) i.next(); x = pcaPoint.getComponentValue(component1); y = pcaPoint.getComponentValue(component2); double survival = pcaPoint.getSurvivalInMonths(); String diseaseName = pcaPoint.getDiseaseName(); if (this.colorBy.equals(PCAcolorByType.NONE)) { Ellipse2D.Double circle = new Ellipse2D.Double(); circle.setFrameFromCenter(x, y, x + 2, y + 2); glyphShape = circle; } else if (diseaseName.equals(RembrandtConstants.NON_TUMOR) || diseaseName.equals("CELL_LINE")) { //glyphShape = ShapeUtilities.createDiamond(new Float(x)); Rectangle2D.Double rect = new Rectangle2D.Double(); rect.setFrameFromCenter(x, y, x + 2, y + 2); glyphShape = rect; Shape gShape = ShapeUtilities.rotateShape(glyphShape, new Double(0.785398163), new Float(x), new Float(y)); glyphShape = gShape; } else if ((survival > 0) && (survival < 10.0)) { Rectangle2D.Double rect = new Rectangle2D.Double(); rect.setFrameFromCenter(x, y, x + 2, y + 2); glyphShape = rect; } else if ((survival > 0) && (survival >= 10.0)) { Ellipse2D.Double circle = new Ellipse2D.Double(); circle.setFrameFromCenter(x, y, x + 2, y + 2); glyphShape = circle; } else { GeneralPath gp = new GeneralPath(); float xf = (float) x; float yf = (float) y; //make a triangle gp.moveTo(xf, yf); gp.lineTo(xf + 3.0f, yf - 3.0f); gp.lineTo(xf - 3.0f, yf - 3.0f); gp.closePath(); glyphShape = gp; } glyphColor = getColorForDataPoint(pcaPoint); glyph = new XYShapeAnnotation(glyphShape, new BasicStroke(1.0f), Color.BLACK, glyphColor); String tooltip = ""; if (pcaPoint.getSurvivalInMonths() <= 0.0) { tooltip = pcaPoint.getSampleId() + " " + pcaPoint.getDiseaseName(); } else { tooltip = pcaPoint.getSampleId() + " " + pcaPoint.getDiseaseName() + " survivalMonths=" + nf.format(pcaPoint.getSurvivalInMonths()); } glyph.setToolTipText(tooltip); plot.addAnnotation(glyph); } }
From source file:gov.nih.nci.ispy.ui.graphing.chart.plot.ISPYPrincipalComponentAnalysisPlot.java
/** * This chart uses the XYAnnotation as a glyph to represent * a single pca data point. Glyph shape is determined by survival time. * Survival of more than 10 months is represented by a circle. 10 months or less * is represented by a square. Component1 values are represented by X * Component2 values are represented by Y *//*from w w w .ja va 2 s .c o m*/ private void createGlyphsAndAddToPlot(XYPlot plot, double glyphScaleFactor) { XYShapeAnnotation glyph; Shape glyphShape = null; Color glyphColor; double glyphSize = 8.0; //pixels double glyphIncrement = (glyphSize * glyphScaleFactor) / 2.0; float gi = (float) glyphIncrement; ISPYPCADataPoint pcaPoint; double x, y; for (Iterator i = dataPoints.iterator(); i.hasNext();) { pcaPoint = (ISPYPCADataPoint) i.next(); x = pcaPoint.getComponentValue(component1); y = pcaPoint.getComponentValue(component2); Double mriPctChange = pcaPoint.getTumorMRIpctChange(); if (mriPctChange == null) { //data is missing Rectangle2D.Double rect = new Rectangle2D.Double(); //rect.setFrameFromCenter(x,y, x+1.25,y+1.25); rect.setFrameFromCenter(x, y, x + glyphIncrement, y + glyphIncrement); glyphShape = rect; } else if (mriPctChange <= -30.0) { //tumor shrank by more than 30% (down arrow) GeneralPath gp = new GeneralPath(); float xf = (float) x; float yf = (float) y; //make a triangle gp.moveTo(xf, yf); gp.lineTo(xf - gi, yf + gi); gp.lineTo(xf + gi, yf + gi); gp.closePath(); glyphShape = gp; } else if (mriPctChange > 0.0) { //tumor size increased (up arrow) GeneralPath gp = new GeneralPath(); float xf = (float) x; float yf = (float) y; //make a triangle gp.moveTo(xf, yf); gp.lineTo(xf + gi, yf - gi); gp.lineTo(xf - gi, yf - gi); gp.closePath(); glyphShape = gp; // Ellipse2D.Double circle = new Ellipse2D.Double(); // circle.setFrameFromCenter(x,y, x+2, y+2); } else if ((mriPctChange > -30.0) && (mriPctChange <= 0.0)) { //no change or reduction in tumor size but less than 30% reduction Ellipse2D.Double circle = new Ellipse2D.Double(); //circle.setFrameFromCenter(x,y,x+1.25,y+1.25); circle.setFrameFromCenter(x, y, x + gi, y + gi); glyphShape = circle; } glyphColor = getColorForDataPoint(pcaPoint); glyph = new XYShapeAnnotation(glyphShape, new BasicStroke(1.0f), Color.BLACK, glyphColor); String tooltip = pcaPoint.toString(); glyph.setToolTipText(tooltip); plot.addAnnotation(glyph); } }
From source file:gov.nih.nci.ispy.ui.graphing.chart.plot.ISPYCorrelationScatterPlot.java
private void createGlyphsAndAddToPlot(XYPlot plot, double xScale, double yScale) { XYShapeAnnotation glyph; Shape glyphShape = null;// w w w .j a v a 2s. c o m Color glyphColor; //double glyphSize = 8.0; //pixels double glyphIncrementX = (glyphSize * xScale) / 2.0; double glyphIncrementY = (glyphSize * yScale) / 2.0; float gi_x = (float) glyphIncrementX; float gi_y = (float) glyphIncrementY; PatientData pd; double x, y; Double mriPctChange = null; for (ISPYPlotPoint corrPoint : dataPoints) { x = corrPoint.getX(); y = corrPoint.getY(); mriPctChange = corrPoint.getMRITumorPctChange(); if (mriPctChange == null) { //data is missing Rectangle2D.Double rect = new Rectangle2D.Double(); //rect.setFrameFromCenter(x,y, x+1.25,y+1.25); rect.setFrameFromCenter(x, y, x + glyphIncrementX, y + glyphIncrementY); glyphShape = rect; } else if (mriPctChange <= -30.0) { //tumor shrank by more than 30% (down arrow) GeneralPath gp = new GeneralPath(); float xf = (float) x; float yf = (float) y; //make a triangle gp.moveTo(xf, yf); gp.lineTo(xf - gi_x, yf + gi_y); gp.lineTo(xf + gi_x, yf + gi_y); gp.closePath(); glyphShape = gp; } else if (mriPctChange > 0.0) { //tumor size increased (up arrow) GeneralPath gp = new GeneralPath(); float xf = (float) x; float yf = (float) y; //make a triangle gp.moveTo(xf, yf); gp.lineTo(xf + gi_x, yf - gi_y); gp.lineTo(xf - gi_x, yf - gi_y); gp.closePath(); glyphShape = gp; // Ellipse2D.Double circle = new Ellipse2D.Double(); // circle.setFrameFromCenter(x,y, x+2, y+2); } else if ((mriPctChange > -30.0) && (mriPctChange <= 0.0)) { //no change or reduction in tumor size but less than 30% reduction Ellipse2D.Double circle = new Ellipse2D.Double(); //circle.setFrameFromCenter(x,y,x+1.25,y+1.25); circle.setFrameFromCenter(x, y, x + gi_x, y + gi_y); glyphShape = circle; } //glyphColor = Color.BLUE; //later can set color based on glyphColor = getColorForDataPoint(corrPoint); glyph = new XYShapeAnnotation(glyphShape, new BasicStroke(1.0f), Color.BLACK, glyphColor); String tooltip = corrPoint.getTag(); glyph.setToolTipText(tooltip); plot.addAnnotation(glyph); } }