public DisplayHistogram(String title) { this.title = title; addMouseMotionListener(this); }
/** * This method informs the maximum size of this component, which will be the same as the preferred size. */ @Override public Dimension getMaximumSize() { return getPreferredSize(); }
/** * The constructor for this class, which will set its fields' values and get some information * about the histogram. * @param histogram the histogram to be plotted. * @param title the title of the plot. */ public DisplayHistogram(Histogram histogram, String title) { this(title); setHistogram(histogram); }
private void setHistogram(Histogram histogram) { this.histogram = histogram; if(histogram != null) { // Calculate the components dimensions. width = histogram.getNumBins(0) * binWidth; // Get the histogram data. counts = histogram.getBins(0); // Get the max and min counts. maxCount = Integer.MIN_VALUE; for (int c = 0; c < counts.length; c++) { maxCount = Math.max(maxCount, counts[c]); } } repaint(); }
/** * This method will be called when the mouse is moved over the component. It will * set the tooltip text on the component to show the histogram data. */ public void mouseMoved(MouseEvent e) { int x = e.getX(); int y = e.getY(); // Don't show anything out of the plot region. if ((x > border.left) && (x < (border.left + width)) && (y > border.top) && (y < (border.top + height))) { // Convert the X to an index on the histogram. x = (x - border.left) / binWidth; y = counts[x]; setToolTipText((indexMultiplier * x) + ": " + y); } else { setToolTipText(null); } }
histogramPanel.setImage(PlanarImage.wrapRenderedImage(image));
private void setHistogram(Histogram histogram) { this.histogram = histogram; if(histogram != null) { // Calculate the components dimensions. width = histogram.getNumBins(0) * binWidth; // Get the histogram data. counts = histogram.getBins(0); // Get the max and min counts. maxCount = Integer.MIN_VALUE; for (int c = 0; c < counts.length; c++) { maxCount = Math.max(maxCount, counts[c]); } } repaint(); }
/** * This method will be called when the mouse is moved over the component. It will * set the tooltip text on the component to show the histogram data. */ public void mouseMoved(MouseEvent e) { int x = e.getX(); int y = e.getY(); // Don't show anything out of the plot region. if ((x > border.left) && (x < (border.left + width)) && (y > border.top) && (y < (border.top + height))) { // Convert the X to an index on the histogram. x = (x - border.left) / binWidth; y = counts[x]; setToolTipText((indexMultiplier * x) + ": " + y); } else { setToolTipText(null); } }
histogramPanel.setImage(PlanarImage.wrapRenderedImage(image));
/** * This method informs the maximum size of this component, which will be the same as the preferred size. */ @Override public Dimension getMaximumSize() { return getPreferredSize(); }
/** * The constructor for this class, which will set its fields' values and get some information * about the histogram. * @param histogram the histogram to be plotted. * @param title the title of the plot. */ public DisplayHistogram(Histogram histogram, String title) { this(title); setHistogram(histogram); }
public DisplayHistogram(String title) { this.title = title; addMouseMotionListener(this); }
/** * This method informs the minimum size of this component, which will be the same as the preferred size. */ @Override public Dimension getMinimumSize() { return getPreferredSize(); }
public void setImage(PlanarImage wrapRenderedImage) { try { setHistogram((Histogram) HistogramDescriptor.create( wrapRenderedImage, null, 1, 1, new int[] { 65536 }, new double[] { 0 }, new double[] { 65535 }, null).getProperty("histogram")); } catch(Exception e) { e.printStackTrace(); setHistogram(null); } }
/** * This method informs the minimum size of this component, which will be the same as the preferred size. */ @Override public Dimension getMinimumSize() { return getPreferredSize(); }
public void setImage(PlanarImage wrapRenderedImage) { try { setHistogram((Histogram) HistogramDescriptor.create( wrapRenderedImage, null, 1, 1, new int[] { 65536 }, new double[] { 0 }, new double[] { 65535 }, null).getProperty("histogram")); } catch(Exception e) { e.printStackTrace(); setHistogram(null); } }