/** * Creates a sample chart. * * @param dataset the dataset. * * @return A sample chart. */ private JFreeChart createChart(IntervalXYDataset dataset,String s) { final JFreeChart chart = ChartFactory.createXYBarChart( "Histogram Plot: "+s, "Keyword index", false, "frequency", dataset, PlotOrientation.VERTICAL, true, true, false ); XYPlot plot = (XYPlot) chart.getPlot(); final IntervalMarker target = new IntervalMarker(400.0, 700.0); //target.setLabel("Target Range"); target.setLabelFont(new Font("SansSerif", Font.ITALIC, 11)); target.setLabelAnchor(RectangleAnchor.LEFT); target.setLabelTextAnchor(TextAnchor.CENTER_LEFT); target.setPaint(new Color(222, 222, 255, 128)); plot.addRangeMarker(target, Layer.BACKGROUND); return chart; }
@Override public Data process(Data item) { Utils.mapContainsKeys(item, key); IntervalMarker[] marker = new IntervalMarker[Constants.N_PIXELS]; double[] arrivalTime = (double[]) item.get(key); double[] newArrivalTime = new double[arrivalTime.length]; Random rand = new Random(Seed); for (int i = 0; i < arrivalTime.length; i++) { Double effStdDev = Math.sqrt(stdDevGoal * stdDevGoal - stdDevOrigin * stdDevOrigin); Double randomArrTimeOffset = rand.nextGaussian() * effStdDev; newArrivalTime[i] = arrivalTime[i] + randomArrTimeOffset; marker[i] = new IntervalMarker(newArrivalTime[i], newArrivalTime[i] + 10); } item.put(outputKey, newArrivalTime); item.put(outputKey + "marker", marker); return item; }
/** * Hides or displayes the 1SD interval marker. * * @param evt */ private void sd1JCheckBoxMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_sd1JCheckBoxMenuItemActionPerformed Iterator iterator = foldChangeplot.getDomainMarkers(Layer.BACKGROUND).iterator(); while (iterator.hasNext()) { IntervalMarker tempMarker = (IntervalMarker) iterator.next(); if (tempMarker.getLabel().equalsIgnoreCase("1SD")) { if (sd1JCheckBoxMenuItem.isSelected()) { tempMarker.setAlpha(1f); } else { tempMarker.setAlpha(0f); } } } }
/** * Hides or displayes the 2SD interval marker. * * @param evt */ private void sd2JCheckBoxMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_sd2JCheckBoxMenuItemActionPerformed Iterator iterator = foldChangeplot.getDomainMarkers(Layer.BACKGROUND).iterator(); while (iterator.hasNext()) { IntervalMarker tempMarker = (IntervalMarker) iterator.next(); if (tempMarker.getLabel().equalsIgnoreCase("2SD")) { if (sd2JCheckBoxMenuItem.isSelected()) { tempMarker.setAlpha(1f); } else { tempMarker.setAlpha(0f); } } } }
/** * Removes the fold change markers. */ private void removeFoldChangeMarkers() { if (foldChangeplot != null && foldChangeplot.getDomainMarkers(Layer.FOREGROUND) != null) { Iterator iterator = foldChangeplot.getDomainMarkers(Layer.FOREGROUND).iterator(); // store the keys in a list first to escape a ConcurrentModificationException ArrayList<IntervalMarker> tempMarkers = new ArrayList<IntervalMarker>(); while (iterator.hasNext()) { tempMarkers.add((IntervalMarker) iterator.next()); } for (int i = 0; i < tempMarkers.size(); i++) { foldChangeplot.removeDomainMarker(tempMarkers.get(i)); } } }
/** * @param plot plot for the marker * @param startVal start postion * @param endVal end position */ protected void addMarker(XYPlot plot, int startVal, int endVal) { IntervalMarker marker = new IntervalMarker(startVal, endVal); marker.setLabelOffsetType(LengthAdjustmentType.EXPAND); marker.setPaint(new Color(134, 254, 225)); marker.setAlpha((float) 0.60); marker.setLabelFont(new Font("SansSerif", Font.PLAIN, 12)); marker.setLabelPaint(Color.green); marker.setLabelAnchor(RectangleAnchor.TOP_LEFT); marker.setLabelTextAnchor(TextAnchor.TOP_LEFT); plot.addDomainMarker(marker, Layer.BACKGROUND); ValueMarker markStart = new ValueMarker(startVal, new Color(31, 254, 225), new BasicStroke(2.0f)); ValueMarker markEnd = new ValueMarker(endVal, new Color(31, 254, 225), new BasicStroke(2.0f)); plot.addDomainMarker(markStart, Layer.BACKGROUND); plot.addDomainMarker(markEnd, Layer.BACKGROUND); }
/** * Adds a periodicity marker. * * @param plot plot for the marker * @param startVal start postion * @param endVal end position */ protected void addPeriodMarker(XYPlot plot, int startVal, int endVal) { IntervalMarker marker = new IntervalMarker(startVal, endVal); marker.setLabelOffsetType(LengthAdjustmentType.EXPAND); marker.setPaint(new Color(134, 254, 225)); marker.setAlpha((float) 0.60); marker.setLabelFont(new Font("SansSerif", Font.PLAIN, 12)); marker.setLabelPaint(Color.blue); marker.setLabelAnchor(RectangleAnchor.TOP_LEFT); marker.setLabelTextAnchor(TextAnchor.TOP_LEFT); marker.setPaint(Color.blue); plot.addDomainMarker(marker, Layer.BACKGROUND); }
/** * Adds an anomaly marker. * * @param plot plot for the marker * @param startVal start postion * @param endVal end position */ protected void addAnomalyMarker(XYPlot plot, int startVal, int endVal) { IntervalMarker marker = new IntervalMarker(startVal, endVal); marker.setLabelOffsetType(LengthAdjustmentType.EXPAND); marker.setPaint(new Color(134, 254, 225)); marker.setAlpha((float) 0.60); marker.setLabelFont(new Font("SansSerif", Font.PLAIN, 12)); marker.setLabelPaint(Color.pink); marker.setLabelAnchor(RectangleAnchor.TOP_LEFT); marker.setLabelTextAnchor(TextAnchor.TOP_LEFT); marker.setPaint(Color.pink); plot.addDomainMarker(marker, Layer.BACKGROUND); }
/** * Creates a sample chart. * * @param dataset the dataset. * * @return A sample chart. */ private JFreeChart createChart(IntervalXYDataset dataset) { final JFreeChart chart = ChartFactory.createXYBarChart( "XY Series Demo", "X", false, "Y", dataset, PlotOrientation.VERTICAL, true, true, false ); XYPlot plot = (XYPlot) chart.getPlot(); final IntervalMarker target = new IntervalMarker(400.0, 700.0); target.setLabel("Target Range"); target.setLabelFont(new Font("SansSerif", Font.ITALIC, 11)); target.setLabelAnchor(RectangleAnchor.LEFT); target.setLabelTextAnchor(TextAnchor.CENTER_LEFT); target.setPaint(new Color(222, 222, 255, 128)); plot.addRangeMarker(target, Layer.BACKGROUND); return chart; }
@SuppressWarnings("unused") private void setMarker(XYPlot plot) { Iterator<Date> ir = m_dateMarkerMap.keySet().iterator(); int index = 1; while (ir.hasNext()) { Date key = ir.next(); final Marker marker = new IntervalMarker(key.getTime(), m_dateMarkerMap.get(key).getTime()); if (this.m_visualMarkerLabel) marker.setLabel("#" + index); // marker.setLabelAnchor(RectangleAnchor.TOP_RIGHT); // marker.setLabelTextAnchor(TextAnchor.TOP_LEFT); marker.setAlpha(0.3f); //marker.setPaint(this.m_markerColor); plot.addDomainMarker(marker); index++; } }
/** * Draws the band. * * @param g2 the graphics device. * @param plotArea the plot area. * @param dataArea the data area. * @param x the x-coordinate. * @param y the y-coordinate. */ public void draw(Graphics2D g2, Rectangle2D plotArea, Rectangle2D dataArea, double x, double y) { double h = getHeight(g2); Iterator iterator = this.markers.iterator(); while (iterator.hasNext()) { IntervalMarker marker = (IntervalMarker) iterator.next(); double start = Math.max(marker.getStartValue(), this.axis.getRange().getLowerBound()); double end = Math.min(marker.getEndValue(), this.axis.getRange().getUpperBound()); double s = this.axis.valueToJava2D(start, dataArea, RectangleEdge.BOTTOM); double e = this.axis.valueToJava2D(end, dataArea, RectangleEdge.BOTTOM); Rectangle2D r = new Rectangle2D.Double( s, y + this.topOuterGap, e - s, h - this.topOuterGap - this.bottomOuterGap ); Composite originalComposite = g2.getComposite(); g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, marker.getAlpha())); g2.setPaint(marker.getPaint()); g2.fill(r); g2.setPaint(marker.getOutlinePaint()); g2.draw(r); g2.setComposite(originalComposite); g2.setPaint(Color.black); drawStringInRect(g2, r, this.font, marker.getLabel()); } }
/** * Some checks for the getStartValue() and setStartValue() methods. */ public void testGetSetStartValue() { IntervalMarker m = new IntervalMarker(1.0, 2.0); m.addChangeListener(this); this.lastEvent = null; assertEquals(1.0, m.getStartValue(), EPSILON); m.setStartValue(0.5); assertEquals(0.5, m.getStartValue(), EPSILON); assertEquals(m, this.lastEvent.getMarker()); }
/** * Some checks for the getEndValue() and setEndValue() methods. */ public void testGetSetEndValue() { IntervalMarker m = new IntervalMarker(1.0, 2.0); m.addChangeListener(this); this.lastEvent = null; assertEquals(2.0, m.getEndValue(), EPSILON); m.setEndValue(0.5); assertEquals(0.5, m.getEndValue(), EPSILON); assertEquals(m, this.lastEvent.getMarker()); }
/** * Draws the band. * * @param g2 the graphics device. * @param plotArea the plot area. * @param dataArea the data area. * @param x the x-coordinate. * @param y the y-coordinate. */ public void draw(Graphics2D g2, Rectangle2D plotArea, Rectangle2D dataArea, double x, double y) { double h = getHeight(g2); Iterator iterator = this.markers.iterator(); while (iterator.hasNext()) { IntervalMarker marker = (IntervalMarker) iterator.next(); double start = Math.max( marker.getStartValue(), this.axis.getRange().getLowerBound() ); double end = Math.min( marker.getEndValue(), this.axis.getRange().getUpperBound() ); double s = this.axis.valueToJava2D( start, dataArea, RectangleEdge.BOTTOM ); double e = this.axis.valueToJava2D( end, dataArea, RectangleEdge.BOTTOM ); Rectangle2D r = new Rectangle2D.Double( s, y + this.topOuterGap, e - s, h - this.topOuterGap - this.bottomOuterGap ); Composite originalComposite = g2.getComposite(); g2.setComposite(AlphaComposite.getInstance( AlphaComposite.SRC_OVER, marker.getAlpha()) ); g2.setPaint(marker.getPaint()); g2.fill(r); g2.setPaint(marker.getOutlinePaint()); g2.draw(r); g2.setComposite(originalComposite); g2.setPaint(Color.black); drawStringInRect(g2, r, this.font, marker.getLabel()); } }
/** * Draws the band. * * @param g2 the graphics device. * @param plotArea the plot area. * @param dataArea the data area. * @param x the x-coordinate. * @param y the y-coordinate. */ public void draw(Graphics2D g2, Rectangle2D plotArea, Rectangle2D dataArea, double x, double y) { double h = getHeight(g2); Iterator iterator = this.markers.iterator(); while (iterator.hasNext()) { IntervalMarker marker = (IntervalMarker) iterator.next(); double start = Math.max( marker.getStartValue(), this.axis.getRange().getLowerBound() ); double end = Math.min( marker.getEndValue(), this.axis.getRange().getUpperBound() ); double s = this.axis.valueToJava2D( start, dataArea, RectangleEdge.BOTTOM ); double e = this.axis.valueToJava2D( end, dataArea, RectangleEdge.BOTTOM ); Rectangle2D r = new Rectangle2D.Double( s, y + this.topOuterGap, e - s, h - this.topOuterGap - this.bottomOuterGap ); Composite originalComposite = g2.getComposite(); g2.setComposite(AlphaComposite.getInstance( AlphaComposite.SRC_OVER, marker.getAlpha()) ); g2.setPaint(marker.getPaint()); g2.fill(r); g2.setPaint(marker.getOutlinePaint()); g2.draw(r); g2.setComposite(originalComposite); g2.setPaint(Color.BLACK); drawStringInRect(g2, r, this.font, marker.getLabel()); } }
protected IntervalMarker createMarker() { Double startValue = getDoubleProperty(PROPERTY_START_VALUE); Double endValue = getDoubleProperty(PROPERTY_END_VALUE); if ( startValue == null || endValue == null ) { return null; } IntervalMarker marker = new IntervalMarker(startValue, endValue); configureMarker(marker); Float strokeWidth = getFloatProperty(PROPERTY_STROKE_WIDTH); if ( strokeWidth != null && strokeWidth > 0 ) { BasicStroke basicStroke = getStroke(strokeWidth); marker.setOutlineStroke(basicStroke); Color outlineColor = JRColorUtil.getColor(getProperty(PROPERTY_OUTLINE_COLOR), null); if (outlineColor != null) { marker.setOutlinePaint(outlineColor); } } return marker; }
@Override public Data process(Data item) { Utils.mapContainsKeys(item, dataKey, "NROI"); if (integralGains == null) { integralGains = loadIntegralGainFile(url); } int roi = (Integer) item.get("NROI"); double[] data = (double[]) item.get(dataKey); int[] positions = new int[Constants.N_PIXELS]; IntervalMarker[] mPositions = new IntervalMarker[Constants.N_PIXELS]; double[] photonCharge = new double[Constants.N_PIXELS]; IntervalMarker[] mPhotonCharge = new IntervalMarker[Constants.N_PIXELS]; Utils.checkWindow(startSearchWindow, rangeSearchWindow, rangeHalfHeightWindow + validMinimalSlice, roi); for (int pix = 0; pix < Constants.N_PIXELS; pix++) { positions[pix] = calculateMaxPosition(pix, startSearchWindow, startSearchWindow + rangeSearchWindow, roi, data); mPositions[pix] = new IntervalMarker(positions[pix], positions[pix] + 1); int halfHeightPos = calculatePositionHalfHeight(pix, positions[pix], positions[pix] - rangeHalfHeightWindow, roi, data); Utils.checkWindow(halfHeightPos, integrationWindow, validMinimalSlice, roi); photonCharge[pix] = calculateIntegral(pix, halfHeightPos, integrationWindow, roi, data) / integralGains[pix]; mPhotonCharge[pix] = new IntervalMarker(halfHeightPos, halfHeightPos + integrationWindow); } item.put(outputKeyMaxAmplPos, positions); item.put(outputKeyMaxAmplPos + "Marker", mPositions); item.put(outputKeyPhotonCharge, photonCharge); item.put("@photoncharge", photonCharge); item.put(outputKeyPhotonCharge + "Marker", mPhotonCharge); return item; }
@Override public Data process(Data item) { roi = (Integer) item.get("NROI"); double[] data = (double[]) item.get(dataKey); double[] baseline = new double[Constants.N_PIXELS]; double[] mBslLevel = new double[data.length]; IntervalMarker[] mBslRange = new IntervalMarker[Constants.N_PIXELS]; for (int pix = 0; pix < Constants.N_PIXELS; pix++) { int firstSl = pix * roi + firstSlice; int lastSl = firstSl + range; if (lastSl > roi * (pix + 1)) { //put here a runtime exeption } for (int slice = firstSl; slice < lastSl; slice++) { baseline[pix] += data[slice]; } baseline[pix] /= range; mBslRange[pix] = new IntervalMarker(firstSlice, firstSlice + range); for (int slice = firstSl; slice < lastSl; slice++) { mBslLevel[slice] = baseline[pix]; } } item.put(outputKey, baseline); item.put(outputKey + "_range", mBslRange); item.put(outputKey + "_level", mBslLevel); return item; }
@Override public Set<SeriesKeySelectorItem> filterItems(Data item) { Set<SeriesKeySelectorItem> newItems = new HashSet<>(); for (String key : item.keySet()) { try { IntervalMarker[] i = (IntervalMarker[]) item.get(key); if (i != null && i.length == Constants.N_PIXELS) { newItems.add(new SeriesKeySelectorItem(key, Color.LIGHT_GRAY, this)); } } catch (ClassCastException e) { continue; } } return newItems; }
public JumpInfos(int numberOfPixel, int numberOfPatches, int roi) { averJumpHeights = new double[numberOfPatches]; posMarkerUp = new IntervalMarker[numberOfPixel]; posMarkerDown = new IntervalMarker[numberOfPixel]; fftResults = new double[numberOfPixel * roi]; pixelWithSpikes = new PixelSet(); pixelWithSignalFlanks = new PixelSet(); pixelWithRinging = new PixelSet(); pixelWithCorrectedJumps = new PixelSet(); pixelWithWrongTimeDepend = new PixelSet(); }
public void addPosMarkerForPatch(int patch, short pos, boolean isStartCell) { for (int px = 0; px < 9; px++) { if (isStartCell == true) { posMarkerUp[patch * 9 + px] = new IntervalMarker(pos, pos + 1); } else { posMarkerDown[patch * 9 + px] = new IntervalMarker(pos, pos + 1); } } }
public void addSpike(int px, int sl, short startCell, double spikeHeight, double averTopSlope) { spikesSet.addById(px); spPixel.add(px); spLogSlice.add(sl); spPhysSpike.add((sl + startCell) % 1024); spHeight.add(spikeHeight); spTopSlope.add(averTopSlope); spikeMarker[px] = new IntervalMarker(sl, sl + 1); }
public static Marker getDateIntervalMarker(Date paramDate1, Date paramDate2, String paramString) { double d1 = paramDate1.getTime(); double d2 = paramDate2.getTime(); BasicStroke localBasicStroke = new BasicStroke(0.3F); IntervalMarker localIntervalMarker = new IntervalMarker(d1, d2, Color.pink, localBasicStroke, Color.black, localBasicStroke, 0.5F); localIntervalMarker.setLabel(paramString); localIntervalMarker.setLabelAnchor(RectangleAnchor.BOTTOM); localIntervalMarker.setLabelTextAnchor(TextAnchor.BOTTOM_CENTER); return localIntervalMarker; }
public void addRangeMarker(CategoryPlot plot, cfCHARTRANGEMARKERData rmData) throws cfmRunTimeException { IntervalMarker rangeMarker = new IntervalMarker(rmData.getStart(), rmData.getEnd()); rangeMarker.setPaint(convertStringToColor(rmData.getColor())); if (rmData.getLabel() != null) { rangeMarker.setLabel(rmData.getLabel()); rangeMarker.setLabelPaint(convertStringToColor(rmData.getLabelColor())); String labelPos = rmData.getLabelPosition(); if (labelPos.equals("top_left")) { rangeMarker.setLabelAnchor(RectangleAnchor.TOP_LEFT); rangeMarker.setLabelTextAnchor(TextAnchor.TOP_LEFT); } else if (labelPos.equals("top")) { rangeMarker.setLabelAnchor(RectangleAnchor.TOP); rangeMarker.setLabelTextAnchor(TextAnchor.TOP_CENTER); } else if (labelPos.equals("top_right")) { rangeMarker.setLabelAnchor(RectangleAnchor.TOP_RIGHT); rangeMarker.setLabelTextAnchor(TextAnchor.TOP_RIGHT); } else if (labelPos.equals("left")) { rangeMarker.setLabelAnchor(RectangleAnchor.LEFT); rangeMarker.setLabelTextAnchor(TextAnchor.CENTER_LEFT); } else if (labelPos.equals("center")) { rangeMarker.setLabelAnchor(RectangleAnchor.CENTER); rangeMarker.setLabelTextAnchor(TextAnchor.CENTER); } else if (labelPos.equals("right")) { rangeMarker.setLabelAnchor(RectangleAnchor.RIGHT); rangeMarker.setLabelTextAnchor(TextAnchor.CENTER_RIGHT); } else if (labelPos.equals("bottom_left")) { rangeMarker.setLabelAnchor(RectangleAnchor.BOTTOM_LEFT); rangeMarker.setLabelTextAnchor(TextAnchor.BOTTOM_LEFT); } else if (labelPos.equals("bottom")) { rangeMarker.setLabelAnchor(RectangleAnchor.BOTTOM); rangeMarker.setLabelTextAnchor(TextAnchor.BOTTOM_CENTER); } else if (labelPos.equals("bottom_right")) { rangeMarker.setLabelAnchor(RectangleAnchor.BOTTOM_RIGHT); rangeMarker.setLabelTextAnchor(TextAnchor.BOTTOM_RIGHT); } rangeMarker.setLabelOffsetType(LengthAdjustmentType.NO_CHANGE); rangeMarker.setLabelFont(getFont(rmData.getFont(), rmData.getFontBold(), rmData.getFontItalic(), rmData.getFontSize())); } plot.addRangeMarker(rangeMarker, Layer.BACKGROUND); }
public void addRangeMarker(XYPlot plot, cfCHARTRANGEMARKERData rmData) throws cfmRunTimeException { IntervalMarker rangeMarker = new IntervalMarker(rmData.getStart(), rmData.getEnd()); rangeMarker.setPaint(convertStringToColor(rmData.getColor())); if (rmData.getLabel() != null) { rangeMarker.setLabel(rmData.getLabel()); rangeMarker.setLabelPaint(convertStringToColor(rmData.getLabelColor())); String labelPos = rmData.getLabelPosition(); if (labelPos.equals("top_left")) { rangeMarker.setLabelAnchor(RectangleAnchor.TOP_LEFT); rangeMarker.setLabelTextAnchor(TextAnchor.TOP_LEFT); } else if (labelPos.equals("top")) { rangeMarker.setLabelAnchor(RectangleAnchor.TOP); rangeMarker.setLabelTextAnchor(TextAnchor.TOP_CENTER); } else if (labelPos.equals("top_right")) { rangeMarker.setLabelAnchor(RectangleAnchor.TOP_RIGHT); rangeMarker.setLabelTextAnchor(TextAnchor.TOP_RIGHT); } else if (labelPos.equals("left")) { rangeMarker.setLabelAnchor(RectangleAnchor.LEFT); rangeMarker.setLabelTextAnchor(TextAnchor.CENTER_LEFT); } else if (labelPos.equals("center")) { rangeMarker.setLabelAnchor(RectangleAnchor.CENTER); rangeMarker.setLabelTextAnchor(TextAnchor.CENTER); } else if (labelPos.equals("right")) { rangeMarker.setLabelAnchor(RectangleAnchor.RIGHT); rangeMarker.setLabelTextAnchor(TextAnchor.CENTER_RIGHT); } else if (labelPos.equals("bottom_left")) { rangeMarker.setLabelAnchor(RectangleAnchor.BOTTOM_LEFT); rangeMarker.setLabelTextAnchor(TextAnchor.BOTTOM_LEFT); } else if (labelPos.equals("bottom")) { rangeMarker.setLabelAnchor(RectangleAnchor.BOTTOM); rangeMarker.setLabelTextAnchor(TextAnchor.BOTTOM_CENTER); } else if (labelPos.equals("bottom_right")) { rangeMarker.setLabelAnchor(RectangleAnchor.BOTTOM_RIGHT); rangeMarker.setLabelTextAnchor(TextAnchor.BOTTOM_RIGHT); } rangeMarker.setLabelOffsetType(LengthAdjustmentType.NO_CHANGE); rangeMarker.setLabelFont(getFont(rmData.getFont(), rmData.getFontBold(), rmData.getFontItalic(), rmData.getFontSize())); } plot.addRangeMarker(rangeMarker, org.jfree.ui.Layer.BACKGROUND); }