Chart.java
上传用户:mingda
上传日期:2017-06-20
资源大小:27691k
文件大小:135k
- double d1 = getHighestValue(i);
- double d2 = getLowestValue(i);
- if(i == 0)
- {
- for(Enumeration enumeration = targetsValue.elements(); enumeration.hasMoreElements();)
- d1 = Math.max(((Double)enumeration.nextElement()).doubleValue(), d1);
- }
- if(d1 > 0.0D)
- setRange(i, d1 * Math.abs(d));
- else
- if(d1 == 0.0D && d2 == 0.0D)
- setRange(i, 100D);
- else
- setRange(i, 0.0D);
- }
- public boolean isPrintAsBitmap()
- {
- return printAsBitmap;
- }
- public int addOverlayChart(Chart chart)
- {
- if(chart != null)
- {
- chart.overlayChartOn = true;
- chart.parentChart = this;
- overlayCharts.addElement(chart);
- chart.setRange(0, getRange(0));
- chart.setRange(1, getRange(1));
- chart.setLowerRange(0, getLowerRange(0));
- chart.setLowerRange(1, getLowerRange(1));
- hasChanged = true;
- autoRepaint();
- return overlayCharts.lastIndexOf(chart);
- } else
- {
- return 0;
- }
- }
- public int getLastSelectedSeries()
- {
- return lastSelectedSeries;
- }
- public synchronized void setRange(int i, double d)
- {
- i = Math.max(0, Math.min(1, i));
- upperRange[i] = d;
- currentUpperRange[i] = Math.min(currentUpperRange[i], d);
- if(!rangeAdjusterOn[i])
- currentUpperRange[i] = d;
- for(int j = 0; j < overlayCharts.size(); j++)
- ((Chart)overlayCharts.elementAt(j)).setRange(i, d);
- hasChanged = true;
- autoRepaint();
- }
- public synchronized double getRange(int i)
- {
- return upperRange[Math.max(0, Math.min(1, i))];
- }
- public void setCurrentLowerRange(int i, double d)
- {
- i = Math.min(currentLowerRange.length - 1, Math.max(0, i));
- int j = rangeAdjusted[i];
- if(i == 0 && j == 2)
- j = 0;
- else
- if(i == 1 && j == 2)
- j = 1;
- d = Math.max(lowerRange[j], d);
- d = Math.min(currentUpperRange[j], d);
- currentLowerRange[j] = d;
- hasChanged = true;
- autoRepaint();
- }
- public double getCurrentLowerRange(int i)
- {
- i = Math.min(currentLowerRange.length - 1, Math.max(0, i));
- return currentLowerRange[i];
- }
- /**
- * @deprecated Method setRange is deprecated
- */
- public synchronized void setRange(double d)
- {
- setRange(0, d);
- }
- /**
- * @deprecated Method getRange is deprecated
- */
- public synchronized long getRange()
- {
- return (long)getRange(0);
- }
- /**
- * @deprecated Method setCurrentLowerRange is deprecated
- */
- public void setCurrentLowerRange(double d)
- {
- setCurrentLowerRange(0, d);
- }
- /**
- * @deprecated Method getCurrentLowerRange is deprecated
- */
- public double getCurrentLowerRange()
- {
- return getCurrentLowerRange(0);
- }
- public Rectangle getDataBounds(Rectangle rectangle)
- {
- chartDataBounds.setBounds(rectangle);
- double d = 1.0D - leftScrollerFactor - rightScrollerFactor;
- if(gridAlignment == 1)
- {
- chartDataBounds.width = (int)Math.round((double)rectangle.width / d);
- chartDataBounds.x -= Math.round(leftScrollerFactor * (double)chartDataBounds.width);
- } else
- {
- chartDataBounds.height = (int)Math.round((double)rectangle.height / d);
- chartDataBounds.y -= Math.round(leftScrollerFactor * (double)chartDataBounds.height);
- }
- return chartDataBounds;
- }
- void calculateZeroLines(Rectangle rectangle)
- {
- for(int i = 0; i < zeroLine.length; i++)
- if(currentUpperRange[i] - currentLowerRange[i] != 0.0D)
- if(gridAlignment == 1)
- {
- int j = (int)Math.round((double)rectangle.height * (currentUpperRange[i] / (currentUpperRange[i] - currentLowerRange[i])));
- zeroLine[i] = rectangle.y + j;
- } else
- {
- int k = (int)Math.round((double)rectangle.width * (currentUpperRange[i] / (currentUpperRange[i] - currentLowerRange[i])));
- zeroLine[i] = (rectangle.x + rectangle.width) - k;
- }
- }
- public void setRangePosition(int i, int j)
- {
- rangePosition[Math.min(1, Math.max(0, i))] = Math.min(1, Math.max(0, j));
- hasChanged = true;
- autoRepaint();
- }
- public int getRangePosition(int i)
- {
- return rangePosition[Math.min(1, Math.max(0, i))];
- }
- public boolean isTitleOn()
- {
- return chartTitleOn;
- }
- public void setLegendPosition(int i)
- {
- if(i == 2 || i == 3 || i == 0 || i == 1)
- {
- legendPosition = i;
- hasChanged = true;
- autoRepaint();
- } else
- {
- throw new IllegalArgumentException("Should be TOP, BOTTOM, LEFT, or RIGHT");
- }
- }
- public int getLegendPosition()
- {
- return legendPosition;
- }
- public void addImage(String s, Image image)
- {
- if(s != null)
- try
- {
- if(image != null)
- {
- images.put(s, image);
- imageTracker.addImage(image, 0);
- imageTracker.waitForAll();
- } else
- {
- images.remove(s);
- }
- }
- catch(InterruptedException interruptedexception)
- {
- interruptedexception.printStackTrace();
- }
- }
- public void setRangeDecimalCount(int i, int j)
- {
- i = Math.max(0, Math.min(rangeDecimalCount.length - 1, i));
- rangeDecimalCount[i] = j;
- hasChanged = true;
- autoRepaint();
- }
- public int getRangeDecimalCount(int i)
- {
- i = Math.max(0, Math.min(rangeDecimalCount.length - 1, i));
- return rangeDecimalCount[i];
- }
- /**
- * @deprecated Method setRangeDecimalCount is deprecated
- */
- public void setRangeDecimalCount(int i)
- {
- setRangeDecimalCount(0, i);
- }
- public void setLegendColors(Color acolor[])
- {
- legendColors = acolor;
- hasChanged = true;
- autoRepaint();
- }
- public Color[] getLegendColors()
- {
- return legendColors;
- }
- /**
- * @deprecated Method getRangeDecimalCount is deprecated
- */
- public int getRangeDecimalCount()
- {
- return getRangeDecimalCount(0);
- }
- public static void main(String args[])
- {
- System.out.println("webgraph " + getVersion());
- System.out.println("Copyright 2002-2003, 方成公司.");
- }
- public void setSampleColor(int i, Color color)
- {
- if(i < 0)
- {
- throw new IllegalArgumentException("Negativ index");
- } else
- {
- sampleColors[i % sampleColors.length] = color;
- hasChanged = true;
- autoRepaint();
- return;
- }
- }
- public Color getSampleColor(int i)
- {
- Color color = DEFAULT_SAMPLE_COLORS[i % DEFAULT_SAMPLE_COLORS.length];
- if(sampleColors != null && sampleColors.length > 0)
- {
- color = sampleColors[i % sampleColors.length];
- if(color == null)
- {
- int j = Math.min(sampleColors.length, DEFAULT_SAMPLE_COLORS.length);
- color = DEFAULT_SAMPLE_COLORS[i % j];
- }
- }
- return color;
- }
- private void paintSampleScroller(Graphics g, Rectangle rectangle)
- {
- if(gridAlignment == 1)
- {
- int i = rectangle.x;
- int k = rectangle.y + rectangle.height + 1;
- if(display3dOn)
- {
- i -= depth3dPoint.x;
- k -= depth3dPoint.y;
- }
- sampleScrollerBounds.x = i;
- sampleScrollerBounds.y = k;
- sampleScrollerBounds.height = 8;
- sampleScrollerBounds.width = rectangle.width;
- g.setColor(getBackground().darker());
- g.drawLine(i, k + 4, i + sampleScrollerBounds.width, k + 4);
- g.setColor(getBackground().brighter());
- g.drawLine(i, k + 5, i + sampleScrollerBounds.width, k + 5);
- paintBox(g, Color.lightGray, i, k, 8, 8, leftPushed);
- i += leftPushed ? 1 : 0;
- g.setColor(Color.black);
- g.drawLine(i + 3, k + 4, i + 3, k + 4);
- g.drawLine(i + 4, k + 3, i + 4, k + 5);
- g.drawLine(i + 5, k + 2, i + 5, k + 6);
- i = (sampleScrollerBounds.x + sampleScrollerBounds.width) - 8;
- paintBox(g, Color.lightGray, i, k, 8, 8, rightPushed);
- i += rightPushed ? 1 : 0;
- g.setColor(Color.black);
- g.drawLine(i + 3, k + 2, i + 3, k + 6);
- g.drawLine(i + 4, k + 3, i + 4, k + 5);
- g.drawLine(i + 5, k + 4, i + 5, k + 4);
- sampleScrollerSpace = sampleScrollerBounds.width - 18;
- int i1 = (int)Math.round(leftScrollerFactor * (double)sampleScrollerSpace);
- i = rectangle.x + 9 + i1;
- if(display3dOn)
- i -= depth3dPoint.x;
- int k1 = sampleScrollerSpace - (int)Math.round(rightScrollerFactor * (double)sampleScrollerSpace) - i1;
- leftAdjusterPos = i;
- rightAdjusterPos = leftAdjusterPos + k1;
- paintBox(g, Color.lightGray, i, k, k1, 8, false);
- g.setColor(Color.gray);
- g.drawLine(i + 2, k + 1, i + 2, k + 7);
- g.setColor(Color.white);
- g.drawLine((i + k1) - 2, k + 1, (i + k1) - 2, k + 7);
- } else
- {
- int j = rectangle.x - 10;
- int l = rectangle.y;
- if(display3dOn)
- {
- j -= depth3dPoint.x;
- l -= depth3dPoint.y;
- }
- sampleScrollerBounds.x = j;
- sampleScrollerBounds.y = l;
- sampleScrollerBounds.height = rectangle.height;
- sampleScrollerBounds.width = 7;
- g.setColor(getBackground().darker());
- g.drawLine(j + 4, l, j + 4, l + sampleScrollerBounds.height);
- g.setColor(getBackground().brighter());
- g.drawLine(j + 5, l, j + 5, l + sampleScrollerBounds.height);
- paintBox(g, Color.lightGray, j, l, 8, 8, leftPushed);
- l += leftPushed ? 1 : 0;
- g.setColor(Color.black);
- g.drawLine(j + 4, l + 3, j + 4, l + 3);
- g.drawLine(j + 3, l + 4, j + 5, l + 4);
- g.drawLine(j + 2, l + 5, j + 6, l + 5);
- l = (sampleScrollerBounds.y + sampleScrollerBounds.height) - 8;
- paintBox(g, Color.lightGray, j, l, 8, 8, rightPushed);
- l += rightPushed ? 1 : 0;
- g.setColor(Color.black);
- g.drawLine(j + 4, l + 5, j + 4, l + 5);
- g.drawLine(j + 3, l + 4, j + 5, l + 4);
- g.drawLine(j + 2, l + 3, j + 6, l + 3);
- sampleScrollerSpace = sampleScrollerBounds.height - 18;
- int j1 = (int)Math.round(leftScrollerFactor * (double)sampleScrollerSpace);
- l = rectangle.y + 9 + j1;
- if(display3dOn)
- l -= depth3dPoint.y;
- int l1 = sampleScrollerSpace - (int)Math.round(rightScrollerFactor * (double)sampleScrollerSpace) - j1;
- leftAdjusterPos = l;
- rightAdjusterPos = leftAdjusterPos + l1;
- paintBox(g, Color.lightGray, j, l, 8, l1, false);
- g.setColor(Color.gray);
- g.drawLine(j + 1, l + 2, j + 7, l + 2);
- g.setColor(Color.white);
- g.drawLine(j + 1, (l + l1) - 2, j + 7, (l + l1) - 2);
- }
- }
- public void setLegendOn(boolean flag)
- {
- legendOn = flag;
- legend.width = 0;
- hasChanged = true;
- autoRepaint();
- }
- public synchronized void setSamples(int i, ChartSample achartsample[])
- {
- chartData.setSamples(i, achartsample);
- hasChanged = true;
- if(isValueLabelsOn(i) && getLabelAngle("valueLabelAngle") != 0)
- angledLabelCache.clear();
- labelSizeCache.clear();
- autoRepaint();
- }
- public synchronized ChartSample[] getSamples(int i)
- {
- return chartData.getSamples(i);
- }
- protected abstract void renderData(Graphics g, Rectangle rectangle, Rectangle rectangle1);
- public double getMinValue(int i)
- {
- return chartData.getMinValue(i);
- }
- public String toString()
- {
- return getTitle();
- }
- public void setGridLine(int i, double d)
- {
- if(i >= maxGridLineCount || i < 0)
- throw new IllegalArgumentException("Illegal vertical grid line index: " + i);
- if(gridLines == null)
- {
- gridLines = new double[i + 1];
- for(int j = 0; j < gridLines.length; j++)
- gridLines[j] = -2147483648D;
- }
- if(i >= gridLines.length)
- {
- double ad[] = new double[i + 1];
- System.arraycopy(gridLines, 0, ad, 0, gridLines.length);
- for(int k = gridLines.length; k < ad.length - 1; k++)
- ad[k] = -2147483648D;
- gridLines = ad;
- }
- gridLines[i] = d;
- hasChanged = true;
- autoRepaint();
- }
- public double getGridLine(int i)
- {
- if(gridLines == null || i >= gridLines.length)
- return -2147483648D;
- else
- return gridLines[i];
- }
- public void setChartData(ChartData chartdata)
- {
- chartData = chartdata;
- checkDataIntegrity();
- autoRepaint();
- }
- public ChartData getChartData()
- {
- return chartData;
- }
- public boolean isRangeLabelsOn()
- {
- return rangeLabelsOn;
- }
- public void setValueLabelsOn(boolean flag)
- {
- setValueLabelsOn(-1, flag);
- }
- public void setValueLabelsOn(int i, boolean flag)
- {
- if(i >= 0 && i < valueLabelsOn.length)
- valueLabelsOn[i] = flag;
- else
- if(i == -1)
- {
- for(int j = 0; j < valueLabelsOn.length; j++)
- valueLabelsOn[j] = flag;
- }
- hasChanged = true;
- autoRepaint();
- }
- public synchronized void setRelativeRange(double d)
- {
- setRelativeRangeIndex(0, d);
- }
- public synchronized void setRelativeRange(double d, double d1)
- {
- setRelativeRange(0, d, d1);
- }
- public synchronized void setRelativeRange(int i, double d, double d1)
- {
- i = Math.min(rangeOn.length - 1, Math.max(0, i));
- double d2 = getHighestValue(i);
- double d3 = getLowestValue(i);
- if(i == 0)
- {
- for(Enumeration enumeration = targetsValue.elements(); enumeration.hasMoreElements();)
- d2 = Math.max(((Double)enumeration.nextElement()).doubleValue(), d2);
- }
- if(d2 > 0.0D)
- {
- d1 = Math.abs(d1);
- double d4 = d2 * Math.abs(d);
- if(d1 % 1.0D == 0.0D)
- {
- if(d4 % d1 == 0.0D)
- setRange(i, d4);
- else
- setRange(i, (d4 - d4 % d1) + d1);
- } else
- {
- double d5;
- for(d5 = 0.0D; d5 < d4; d5 += d1);
- setRange(i, d5);
- }
- } else
- if(d2 == 0.0D && d3 == 0.0D)
- setRange(i, 100D);
- else
- setRange(i, 0.0D);
- }
- public void setFont(String s, Font font)
- {
- if(s == null || s.trim().length() < 1)
- return;
- s = s.trim().toLowerCase();
- if(font != null)
- labelFonts.put(s, font);
- else
- labelFonts.remove(s);
- labelSizeCache.clear();
- hasChanged = true;
- autoRepaint();
- }
- public Font getFont(String s)
- {
- if(s == null)
- getFont();
- Font font = (Font)labelFonts.get(s.trim().toLowerCase());
- if(font != null)
- return font;
- else
- return getFont();
- }
- public synchronized void setSeriesLabels(String as[])
- {
- chartData.setSeriesLabels(as);
- hasChanged = true;
- autoRepaint();
- }
- public synchronized String[] getSeriesLabels()
- {
- return chartData.getSeriesLabels();
- }
- /**
- * @deprecated Method getFloatRange is deprecated
- */
- public synchronized double getFloatRange()
- {
- return getRange(0);
- }
- private void adjustRange(Chart chart, int i, double d, double d1)
- {
- if(d != 0.0D)
- {
- double d2 = chart.lowerRange[i] + d * (chart.upperRange[i] - chart.lowerRange[i]);
- if(d2 > chart.currentLowerRange[i])
- chart.currentUpperRange[i] = d2;
- chart.currentUpperRange[i] = Math.min(chart.currentUpperRange[i], chart.upperRange[i]);
- }
- if(d1 != 0.0D)
- {
- double d3 = chart.lowerRange[i] + d1 * (chart.upperRange[i] - chart.lowerRange[i]);
- if(d3 < chart.currentUpperRange[i])
- chart.currentLowerRange[i] = d3;
- chart.currentLowerRange[i] = Math.max(chart.currentLowerRange[i], chart.lowerRange[i]);
- }
- }
- protected abstract void render(Graphics g);
- void render(Graphics g, boolean flag)
- {
- }
- public boolean isValueLabelsOn()
- {
- return isValueLabelsOn(-1);
- }
- public void setRangeOn(int i, boolean flag)
- {
- rangeOn[Math.min(1, Math.max(0, i))] = flag;
- hasChanged = true;
- autoRepaint();
- }
- public boolean isValueLabelsOn(int i)
- {
- if(i >= 0 && i < valueLabelsOn.length)
- return valueLabelsOn[i];
- if(i == -1)
- {
- for(int j = 0; j < valueLabelsOn.length; j++)
- if(!valueLabelsOn[j])
- return false;
- return true;
- } else
- {
- return false;
- }
- }
- public void setSelection(int i, int j, boolean flag)
- {
- setSelection(i, j, flag, false);
- }
- private void setSelection(int i, int j, boolean flag, boolean flag1)
- {
- chartData.setSelection(i, j, flag, flag1);
- lastSelectedSample = -1;
- lastSelectedSeries = -1;
- for(int k = 0; k < legendSelection.length; k++)
- legendSelection[k] = false;
- if(j == -1 && i == -1)
- {
- if(selectedSample != null)
- {
- notifyListeners(this, 2, selectedSample);
- selectedSample = null;
- }
- } else
- if(j == -1 && i != -1)
- {
- ChartSample chartsample = new ChartSample(j);
- chartsample.setSeries(i);
- if(legendLabels != null && i < legendLabels.length && legendLabels[i] != null)
- chartsample.setLabel(legendLabels[i]);
- else
- if(i >= 0 && i < getSeriesCount())
- chartsample.setLabel(getSeriesLabel(i));
- if(flag)
- {
- lastSelectedSeries = i;
- if((selectedSample == null || chartsample.getSeries() != selectedSample.getSeries()) && selectedSample != null)
- notifyListeners(this, 2, selectedSample);
- notifyListeners(this, 1, chartsample);
- selectedSample = chartsample;
- } else
- {
- notifyListeners(this, 2, chartsample);
- if(chartsample == selectedSample)
- selectedSample = null;
- }
- } else
- if(j != -1 && i != -1)
- {
- ChartSample chartsample1 = getSample(i, j);
- if(flag)
- {
- lastSelectedSample = j;
- lastSelectedSeries = i;
- if(selectedSample != null && chartsample1 != selectedSample)
- notifyListeners(this, 2, selectedSample);
- notifyListeners(this, 1, chartsample1);
- selectedSample = chartsample1;
- } else
- {
- notifyListeners(this, 2, chartsample1);
- if(chartsample1 == selectedSample)
- selectedSample = null;
- }
- }
- if(getSeriesCount() > 1 || multiSeriesOn)
- {
- if(i >= 0 && i < legendSelection.length)
- legendSelection[i] = flag;
- } else
- if(j >= 0 && j < legendSelection.length)
- legendSelection[j] = flag;
- if(j == -1)
- {
- for(int l = 0; l < overlayCharts.size(); l++)
- {
- Chart chart = (Chart)overlayCharts.elementAt(l);
- if(chart != null)
- chart.setSelection(i, j, flag, flag1);
- }
- }
- hasChanged = true;
- autoRepaint();
- }
- int getValuePosition(int i, double d, Rectangle rectangle)
- {
- i = Math.min(upperRange.length - 1, Math.max(0, i));
- int j = 0;
- int k = 0;
- if(gridAlignment == 1)
- {
- if(currentUpperRange[i] - currentLowerRange[i] != 0.0D)
- j = (int)((double)rectangle.height * (currentUpperRange[i] / (currentUpperRange[i] - currentLowerRange[i])));
- k = rectangle.y + j;
- } else
- {
- if(currentUpperRange[i] - currentLowerRange[i] != 0.0D)
- j = (int)((double)rectangle.width * (currentUpperRange[i] / (currentUpperRange[i] - currentLowerRange[i])));
- k = (rectangle.x + rectangle.width) - j;
- }
- int l = 0;
- if(currentUpperRange[i] - currentLowerRange[i] != 0.0D)
- if(gridAlignment == 1)
- l = (int)((double)k - (double)rectangle.height * (d / (currentUpperRange[i] - currentLowerRange[i])));
- else
- l = (int)((double)k + (double)rectangle.width * (d / (currentUpperRange[i] - currentLowerRange[i])));
- return l;
- }
- public final void print(Graphics g)
- {
- Dimension dimension = getSize();
- g.setColor(getBackground());
- g.fillRect(0, 0, dimension.width, dimension.height);
- g.setColor(getForeground());
- hasChanged = true;
- render(g, printAsBitmap);
-
- //g.setColor(Color.red);
- //g.setFont(new Font("Dialog", 1, 18));
- //g.drawString("演示版不支持打印,请购买正版!",10,30);
- //c2.paint(g, dimension);
- }
- public void setChartBackground(Color color)
- {
- chartBackground = color;
- hasChanged = true;
- autoRepaint();
- }
- public Color getChartBackground()
- {
- return chartBackground;
- }
- public void setRangeColor(int i, Color color)
- {
- rangeColor[Math.min(1, Math.max(0, i))] = color == null ? chartForeground : color;
- hasChanged = true;
- autoRepaint();
- }
- public Color getRangeColor(int i)
- {
- i = Math.min(1, Math.max(0, i));
- if(rangeColor[i] != null)
- return rangeColor[i];
- else
- return chartForeground;
- }
- public synchronized void setSeriesLabelColor(int i, Color color)
- {
- try
- {
- seriesLabelColors[i] = color;
- hasChanged = true;
- autoRepaint();
- }
- catch(IndexOutOfBoundsException _ex)
- {
- throw new IllegalArgumentException("Invalid series index: " + i);
- }
- }
- public Color getSeriesLabelColor(int i)
- {
- try
- {
- return seriesLabelColors[i];
- }
- catch(IndexOutOfBoundsException _ex)
- {
- throw new IllegalArgumentException("Invalid series index: " + i);
- }
- }
- public synchronized ChartSample getSample(Object obj)
- {
- return chartData.getSample(obj);
- }
- public synchronized int appendSample(int i, ChartSample chartsample, boolean flag)
- {
- int j = chartData.appendSample(i, chartsample, flag);
- checkDataIntegrity();
- hasChanged = true;
- if(isValueLabelsOn(i) && getLabelAngle("valueLabelAngle") != 0)
- angledLabelCache.clear();
- autoRepaint();
- return j;
- }
- public synchronized void setSample(int i, int j, ChartSample chartsample)
- {
- chartData.setSample(i, j, chartsample);
- hasChanged = true;
- if(isValueLabelsOn(i) && getLabelAngle("valueLabelAngle") != 0)
- angledLabelCache.clear();
- autoRepaint();
- }
- public void setLabel(String s, String s1)
- {
- if(s != null && s.length() > 0)
- {
- s = s.toLowerCase().trim();
- if(s1 != null && s1.length() > 0)
- labels.put(s, s1);
- else
- labels.remove(s);
- hasChanged = true;
- if(getLabelAngle(s + "Angle") != 0)
- angledLabelCache.clear();
- autoRepaint();
- }
- }
- public String getLabel(String s)
- {
- if(s != null)
- {
- s = s.toLowerCase().trim();
- return (String)labels.get(s);
- } else
- {
- return null;
- }
- }
- public synchronized ChartSample getSample(int i, int j)
- {
- return chartData.getSample(i, j);
- }
- public void setValueLinesColor(Color color)
- {
- valueLinesColor = color;
- if(valueLinesColor == null)
- valueLinesColor = Color.lightGray;
- hasChanged = true;
- autoRepaint();
- }
- public Color getValueLinesColor()
- {
- return valueLinesColor;
- }
- String getTargetLabel(String s)
- {
- String s1 = "";
- int i = ((Integer)targetsStyle.get(s)).intValue();
- double d = ((Double)targetsValue.get(s)).doubleValue();
- String s2 = formatNumber(d, rangeDecimalCount[0]);
- if(getLabel("rangeLabelPrefix") != null)
- s2 = getLabel("rangeLabelPrefix") + s2;
- if(getLabel("rangeLabelPostfix") != null)
- s2 += getLabel("rangeLabelPostfix");
- switch(i)
- {
- default:
- break;
- case 0: // ' '
- s1 = "";
- break;
- case 1: // ' 01'
- s1 = s;
- break;
- case 2: // ' 02'
- s1 = s2;
- break;
- case 3: // ' 03'
- if(rangePosition[0] == 0)
- s1 = s + " " + s2;
- else
- s1 = s2 + " " + s;
- break;
- }
- return s1;
- }
- public void setLegendColor(int i, Color color)
- {
- if(legendColors == null)
- legendColors = new Color[i + 1];
- if(i >= legendColors.length)
- {
- Color acolor[] = new Color[i + 1];
- System.arraycopy(legendColors, 0, acolor, 0, legendColors.length);
- legendColors = acolor;
- }
- legendColors[i] = color;
- hasChanged = true;
- autoRepaint();
- }
- public Color getLegendColor(int i)
- {
- if(legendColors == null || i >= legendColors.length)
- return getSampleColor(i);
- else
- return legendColors[i];
- }
- public void setRangeAdjusted(int i, int j)
- {
- i = Math.min(rangeAdjusterOn.length - 1, Math.max(0, i));
- j = Math.min(2, Math.max(0, j));
- rangeAdjusted[i] = j;
- }
- public int getRangeAdjusted(int i)
- {
- i = Math.min(rangeAdjusterOn.length - 1, Math.max(0, i));
- return rangeAdjusted[i];
- }
- protected void processEvent(AWTEvent awtevent)
- {
- if(depth3d > -1)
- {
- depth3dPoint.x = depth3d;
- depth3dPoint.y = -depth3d;
- }
- if((awtevent instanceof MouseEvent) && (rangeAdjusterOn[0] || rangeAdjusterOn[1] || sampleScrollerOn))
- handleAdjusters(awtevent);
- switch(awtevent.getID())
- {
- default:
- break;
- case 501:
- /*if(c2.copyright)
- {
- c2.copyright = false;
- } else
- {
- int i = ((MouseEvent)awtevent).getX();
- int k = ((MouseEvent)awtevent).getY();
- Dimension dimension = getSize();
- if(i > 0 && i < 11 && k > dimension.height - 11 && k < dimension.height)
- c2.copyright = true;
- }
- repaint();
- */
- break;
-
- case 502:
- int j = ((MouseEvent)awtevent).getX();
- int l = ((MouseEvent)awtevent).getY();
- ChartSample chartsample = checkSelection(new Point(j, l));
- if(chartsample != null)
- {
- int i1 = chartsample.getSeries();
- if(i1 >= 0)
- {
- setSelection(i1, chartsample.getIndex(), true, true);
- repaint();
- }
- break;
- }
- if(selectedSample != null)
- {
- setSelection(-1, -1, false, true);
- repaint();
- }
- break;
- case 101: // 'e'
- if(offscreen != null)
- offscreen.flush();
- if(!externalGraphicsOn)
- offscreen = null;
- hasChanged = true;
- repaint();
- break;
- }
- super.processEvent(awtevent);
- }
- public double getMaxValue(int i)
- {
- return chartData.getMaxValue(i);
- }
- double getHighestValue(int i)
- {
- i = Math.min(rangeOn.length - 1, Math.max(0, i));
- int j = getSeriesCount();
- double d = 0.0D;
- for(int k = 0; k < j; k++)
- if(getSeriesRange(k) == i)
- d = Math.max(getMaxValue(k), d);
- for(int l = 0; l < overlayCharts.size(); l++)
- {
- Chart chart = (Chart)overlayCharts.elementAt(l);
- if(chart != null && !chart.chartType.equals("pie"))
- {
- for(int i1 = 0; i1 < chart.getSeriesCount(); i1++)
- if(chart.getSeriesRange(i1) == i)
- d = Math.max(chart.getMaxValue(i1), d);
- }
- }
- return d;
- }
- public final void update(Graphics g)
- {
- paint(g);
- }
- private void adjustRangeSlide(Chart chart, int i, double d)
- {
- double d1 = d * (chart.upperRange[i] - chart.lowerRange[i]);
- d1 = gridAlignment != 1 ? -d1 : d1;
- if(d1 >= 0.0D)
- d1 = Math.min(chart.upperRange[i] - chart.currentUpperRange[i], d1);
- else
- if(chart.currentLowerRange[i] + d1 < chart.lowerRange[i])
- d1 = chart.lowerRange[i] - chart.currentLowerRange[i];
- chart.currentUpperRange[i] += d1;
- chart.currentLowerRange[i] += d1;
- }
- public void setTitle(String s)
- {
- if(chartTitle != null)
- {
- Long long1 = new Long(chartTitle.hashCode() + getFont("titleFont").hashCode());
- labelSizeCache.remove(long1);
- }
- chartTitle = s;
- hasChanged = true;
- autoRepaint();
- }
- public String getTitle()
- {
- return chartTitle;
- }
- public void removeOverlayChart(int i)
- {
- if(i >= 0 && i < overlayCharts.size())
- {
- overlayCharts.removeElementAt(i);
- hasChanged = true;
- autoRepaint();
- } else
- {
- throw new IllegalArgumentException("invalid overlay index: " + i);
- }
- }
- private void transform(double d, double d1, double d2, double d3, double ad[])
- {
- ad[0] = d * d2 + d1 * d3;
- ad[1] = d * d3 - d1 * d2;
- }
- public void addItemListener(ItemListener itemlistener)
- {
- if(itemlistener != null)
- listeners.addElement(itemlistener);
- }
- public synchronized void setSampleValues(int i, double ad[])
- {
- chartData.setSampleValues(i, ad);
- hasChanged = true;
- if(isValueLabelsOn(i) && getLabelAngle("valueLabelAngle") != 0)
- angledLabelCache.clear();
- labelSizeCache.clear();
- autoRepaint();
- }
- public synchronized double[] getSampleValues(int i)
- {
- return chartData.getSampleValues(i);
- }
- private void getAngledBounds(double d, double d1, Rectangle rectangle, double ad[])
- {
- double d2 = (1.0D / 0.0D);
- double d3 = (1.0D / 0.0D);
- double d4 = (-1.0D / 0.0D);
- double d5 = (-1.0D / 0.0D);
- int i = 0;
- do
- {
- int j = 0;
- do
- {
- transform(d, d1, rectangle.x + j * rectangle.width, rectangle.y + i * rectangle.height, ad);
- d2 = Math.min(d2, ad[0]);
- d3 = Math.min(d3, ad[1]);
- d4 = Math.max(d4, ad[0]);
- d5 = Math.max(d5, ad[1]);
- } while(++j <= 1);
- } while(++i <= 1);
- rectangle.x = (int)Math.floor(d2);
- rectangle.y = (int)Math.floor(d3);
- rectangle.width = ((int)Math.ceil(d4) - rectangle.x) + 1;
- rectangle.height = ((int)Math.ceil(d5) - rectangle.y) + 1;
- }
- public void setGridLineColors(Color acolor[])
- {
- gridLineColors = acolor;
- hasChanged = true;
- autoRepaint();
- }
- public Color[] getGridLineColors()
- {
- return gridLineColors;
- }
- public void setRangeAdjusterPosition(int i, int j)
- {
- i = Math.min(rangeAdjusterPosition.length - 1, Math.max(0, i));
- rangeAdjusterPosition[i] = Math.min(1, Math.max(0, j));
- }
- public int getRangeAdjusterPosition(int i)
- {
- i = Math.min(rangeAdjusterPosition.length - 1, Math.max(0, i));
- return rangeAdjusterPosition[i];
- }
- public void setTitleOn(boolean flag)
- {
- chartTitleOn = flag;
- hasChanged = true;
- autoRepaint();
- }
- public boolean isAutomaticRepaintOn()
- {
- return automaticRepaintOn;
- }
- public boolean isOverlayChartOn(int i)
- {
- Chart chart = getOverlayChart(i);
- if(chart != null)
- return chart.overlayChartOn;
- else
- return false;
- }
- public void reset()
- {
- automaticRepaintOn = true;
- chartTitle = null;
- chartTitleOn = false;
- sampleDecimalCount = new int[getSeriesCount()];
- legendOn = false;
- legendPosition = 1;
- display3dOn = false;
- chartBackground = Color.white;
- chartForeground = Color.black;
- setForeground(Color.black);
- setBackground(new Color(231, 221, 231));
- labelFonts.clear();
- labels.clear();
- legendLabels = null;
- graphInsets.top = graphInsets.bottom = graphInsets.left = graphInsets.right = -1;
- preferredSize.setSize(300, 200);
- lastSelectedSample = -1;
- lastSelectedSeries = -1;
- setFont(new Font("Arial", 0, 11));
- setFont("titleFont", new Font("Arial", 1, 14));
- setSampleColors(null);
- seriesRange = new int[getSeriesCount()];
- valueLabelsOn = new boolean[getSeriesCount()];
- barLabelStyle = 0;
- overlayChartOn = true;
- servletModeOn = false;
- externalGraphicsOn = false;
- floatingOnLegendOn = true;
- maxValueLineCount = 0x7fffffff;
- maxGridLineCount = 1000;
- leftSampleAxisRange = 0.0D;
- rightSampleAxisRange = 100D;
- valueLinesOn = false;
- valueLinesColor = Color.lightGray;
- rangeLabelsOn = true;
- rangeOn[0] = true;
- rangeOn[1] = false;
- rangeDecimalCount[0] = 0;
- rangeDecimalCount[1] = 0;
- sampleLabelsOn = false;
- targetsLabel.clear();
- targetsValue.clear();
- targetsColor.clear();
- targetsStyle.clear();
- gridAlignment = 1;
- rangeAdjusterOn[0] = false;
- rangeAdjusterOn[1] = false;
- sampleScrollerOn = false;
- setSize(300, 200);
- upperRange[0] = 100D;
- upperRange[1] = 100D;
- lowerRange[0] = 0.0D;
- lowerRange[1] = 0.0D;
- currentUpperRange[0] = 100D;
- currentUpperRange[1] = 100D;
- currentLowerRange[0] = 0.0D;
- currentLowerRange[1] = 0.0D;
- rangeAdjusterPosition[0] = 1;
- rangeAdjusterPosition[1] = 1;
- adjusterIndex = -1;
- rangePosition[0] = 0;
- rangePosition[1] = 1;
- rangeAdjusted[0] = 0;
- rangeAdjusted[1] = 1;
- gridLines = null;
- defaultGridLines = null;
- defaultGridLinesColor = Color.lightGray;
- gridLineColors = null;
- leftSampleAxisRange = 0.0D;
- rightSampleAxisRange = 100D;
- images = new Hashtable();
- imageTracker = new MediaTracker(this);
- }
- public void setMaxValueLineCount(int i)
- {
- if(i > -1)
- maxValueLineCount = i;
- else
- maxValueLineCount = 0x7fffffff;
- hasChanged = true;
- autoRepaint();
- }
- public int getMaxValueLineCount()
- {
- if(maxValueLineCount != 0x7fffffff)
- return maxValueLineCount;
- else
- return -1;
- }
- public synchronized void setSeriesCount(int i)
- {
- chartData.setSeriesCount(i);
- checkDataIntegrity();
- hasChanged = true;
- autoRepaint();
- }
- public synchronized int getSeriesCount()
- {
- return chartData.getSeriesCount();
- }
- public void setSampleColors(Color acolor[])
- {
- if(acolor != null)
- {
- sampleColors = acolor;
- } else
- {
- sampleColors = new Color[DEFAULT_SAMPLE_COLORS.length];
- System.arraycopy(DEFAULT_SAMPLE_COLORS, 0, sampleColors, 0, sampleColors.length);
- }
- hasChanged = true;
- autoRepaint();
- }
- public Color[] getSampleColors()
- {
- return sampleColors;
- }
- protected ChartSample checkSelection(Point point)
- {
- if(legendBounds == null || !legendOn)
- return null;
- ChartSample chartsample = null;
- int i = getSeriesCount();
- int j = getSampleCount();
- if(j > 0 && i > 0)
- {
- for(int k = 0; k < legendBounds.length; k++)
- {
- if(legendBounds[k] == null || !legendBounds[k].contains(point))
- continue;
- if(i > 1 || chartType.equals("line") || multiSeriesOn)
- {
- chartsample = new ChartSample(-1);
- chartsample.setSeries(k);
- } else
- {
- chartsample = getSample(0, k);
- }
- break;
- }
- }
- return chartsample;
- }
- public void setFloatingOnLegendOn(boolean flag)
- {
- floatingOnLegendOn = flag;
- hasChanged = true;
- autoRepaint();
- }
- Dimension getImageSize(String s)
- {
- Dimension dimension = new Dimension(0, 0);
- if(s != null)
- {
- Image image = (Image)images.get(s);
- if(image != null)
- {
- dimension.width = image.getWidth(this);
- dimension.height = image.getHeight(this);
- }
- }
- return dimension;
- }
- Dimension getLabelSize(String s, Font font)
- {
- if(s == null)
- return new Dimension(0, 0);
- if(font == null)
- font = new Font("Dialog", 0, 12);
- Long long1 = new Long(s.hashCode() + font.hashCode());
- Dimension dimension = (Dimension)labelSizeCache.get(long1);
- if(dimension == null)
- {
- FontMetrics fontmetrics = getFontMetrics(font);
- dimension = new Dimension();
- if(s != null)
- {
- for(StringTokenizer stringtokenizer = new StringTokenizer(s, "n"); stringtokenizer.hasMoreElements();)
- {
- String s1 = (String)stringtokenizer.nextElement();
- dimension.height += fontmetrics.getMaxAscent() + 1;
- if(s1 != null)
- dimension.width = Math.max(dimension.width, fontmetrics.stringWidth(s1));
- }
- }
- dimension.height = Math.max(dimension.height, fontmetrics.getMaxAscent());
- if(!servletModeOn)
- labelSizeCache.put(long1, dimension);
- }
- return dimension;
- }
- Dimension getAngledLabelSize(Dimension dimension, int i)
- {
- if(i == 90 || i == 270)
- return new Dimension(dimension.height, dimension.width);
- if(i > 0 && i < 360)
- {
- double d = Math.sin((double)i * 0.017453292519943295D);
- double d1 = Math.cos((double)i * 0.017453292519943295D);
- int j = (int)(Math.abs((double)dimension.width * d1) + Math.abs((double)dimension.height * d) + 0.5D);
- int k = (int)(Math.abs((double)dimension.width * d) + Math.abs((double)dimension.height * d1) + 0.5D);
- return new Dimension(j, k);
- } else
- {
- return dimension;
- }
- }
- public synchronized void setSampleLabel(int i, String s)
- {
- String s1 = getSampleLabel(i);
- chartData.setSampleLabel(i, s);
- hasChanged = true;
- if(sampleLabelsOn && (getLabelAngle("sampleLabelAngle") != 0 || getLabelAngle("barLabelAngle") != 0))
- angledLabelCache.clear();
- if(s1 != null)
- {
- Long long1 = new Long(s1.hashCode() + getFont("sampleLabelFont").hashCode());
- labelSizeCache.remove(long1);
- long1 = new Long(s1.hashCode() + getFont("barLabelFont").hashCode());
- labelSizeCache.remove(long1);
- }
- autoRepaint();
- }
- public synchronized String getSampleLabel(int i)
- {
- return chartData.getSampleLabel(i);
- }
- public void setRangeAdjusterOn(int i, boolean flag)
- {
- i = Math.min(rangeAdjusterOn.length - 1, Math.max(0, i));
- rangeAdjusterOn[i] = flag;
- if(!flag)
- {
- int j = rangeAdjusted[i];
- if(i == 0 && j == 2)
- j = 0;
- else
- if(i == 1 && j == 2)
- j = 1;
- setCurrentRange(i, getRange(j));
- setCurrentLowerRange(i, getLowerRange(j));
- }
- hasChanged = true;
- autoRepaint();
- }
- public boolean isSampleScrollerOn()
- {
- return sampleScrollerOn;
- }
- protected synchronized void checkDataIntegrity()
- {
- int i = chartData.getSeriesCount();
- if(i != seriesLabelColors.length)
- {
- hasChanged = true;
- Color acolor[] = new Color[i];
- int j = Math.min(i, seriesLabelColors.length);
- System.arraycopy(seriesLabelColors, 0, acolor, 0, j);
- seriesLabelColors = acolor;
- int ai[] = new int[i];
- System.arraycopy(seriesRange, 0, ai, 0, Math.min(seriesRange.length, ai.length));
- seriesRange = ai;
- int ai1[] = new int[i];
- System.arraycopy(sampleDecimalCount, 0, ai1, 0, Math.min(sampleDecimalCount.length, ai1.length));
- sampleDecimalCount = ai1;
- boolean aflag1[] = new boolean[i];
- System.arraycopy(valueLabelsOn, 0, aflag1, 0, Math.min(valueLabelsOn.length, aflag1.length));
- valueLabelsOn = aflag1;
- }
- String as[] = getLegendLabels();
- if(legendSelection.length != as.length)
- {
- boolean aflag[] = new boolean[as.length];
- System.arraycopy(legendSelection, 0, aflag, 0, Math.min(legendSelection.length, aflag.length));
- legendSelection = aflag;
- }
- int k = chartData.getSampleCount();
- if(k != sampleLabelColors.length)
- {
- hasChanged = true;
- Color acolor1[] = new Color[k];
- int l = Math.min(k, sampleLabelColors.length);
- System.arraycopy(sampleLabelColors, 0, acolor1, 0, l);
- sampleLabelColors = acolor1;
- }
- }
- /**
- * @deprecated Method setRangeAdjusterOn is deprecated
- */
- public void setRangeAdjusterOn(boolean flag)
- {
- setRangeAdjusterOn(0, flag);
- }
- public void setPreferredSize(int i, int j)
- {
- preferredSize.width = i;
- preferredSize.height = j;
- }
- public Dimension getPreferredSize()
- {
- return new Dimension(preferredSize);
- }
- public Dimension getMinimumSize()
- {
- return new Dimension(100, 70);
- }
- private void handleAdjusters(AWTEvent awtevent)
- {
- boolean flag = false;
- boolean flag1 = false;
- boolean flag2 = false;
- boolean flag3 = false;
- boolean flag4 = false;
- boolean flag5 = false;
- insideLeftButton = false;
- insideRightButton = false;
- int i = -1;
- int j = ((MouseEvent)awtevent).getX();
- int k = ((MouseEvent)awtevent).getY();
- if(gridAlignment == 1)
- {
- flag = j >= rangeAdjusterBounds[0].x && j <= rangeAdjusterBounds[0].x + rangeAdjusterBounds[0].width;
- flag = flag && k >= rangeAdjusterBounds[0].y - 3 && k <= rangeAdjusterBounds[0].y + rangeAdjusterBounds[0].height + 1;
- flag1 = k >= rangeAdjusterBounds[0].y - 1 && k <= rangeAdjusterBounds[0].y + 3;
- flag2 = k >= (rangeAdjusterBounds[0].y + rangeAdjusterBounds[0].height) - 3 && k <= rangeAdjusterBounds[0].y + rangeAdjusterBounds[0].height + 1;
- i = !flag && !flag1 && !flag2 ? -1 : 0;
- if(rangeAdjusterOn[1] && !flag)
- {
- flag = j >= rangeAdjusterBounds[1].x && j <= rangeAdjusterBounds[1].x + rangeAdjusterBounds[1].width;
- flag = flag && k >= rangeAdjusterBounds[1].y - 3 && k <= rangeAdjusterBounds[1].y + rangeAdjusterBounds[1].height + 1;
- flag1 = k >= rangeAdjusterBounds[1].y - 1 && k <= rangeAdjusterBounds[1].y + 3;
- flag2 = k >= (rangeAdjusterBounds[1].y + rangeAdjusterBounds[1].height) - 3 && k <= rangeAdjusterBounds[1].y + rangeAdjusterBounds[1].height + 1;
- i = !flag && !flag1 && !flag2 ? -1 : 1;
- }
- } else
- {
- flag = k >= rangeAdjusterBounds[0].y && k <= rangeAdjusterBounds[0].y + rangeAdjusterBounds[0].height;
- flag = flag && j >= rangeAdjusterBounds[0].x - 1 && j <= rangeAdjusterBounds[0].x + rangeAdjusterBounds[0].width + 1;
- flag2 = j >= rangeAdjusterBounds[0].x - 1 && j <= rangeAdjusterBounds[0].x + 2;
- flag1 = j >= (rangeAdjusterBounds[0].x + rangeAdjusterBounds[0].width) - 3 && j <= rangeAdjusterBounds[0].x + rangeAdjusterBounds[0].width + 1;
- i = !flag && !flag1 && !flag2 ? -1 : 0;
- if(rangeAdjusterOn[1] && !flag)
- {
- flag = k >= rangeAdjusterBounds[1].y && k <= rangeAdjusterBounds[1].y + rangeAdjusterBounds[1].height;
- flag = flag && j >= rangeAdjusterBounds[1].x - 1 && j <= rangeAdjusterBounds[1].x + rangeAdjusterBounds[1].width + 1;
- flag2 = j >= rangeAdjusterBounds[1].x - 1 && j <= rangeAdjusterBounds[1].x + 2;
- flag1 = j >= (rangeAdjusterBounds[1].x + rangeAdjusterBounds[1].width) - 3 && j <= rangeAdjusterBounds[1].x + rangeAdjusterBounds[1].width + 1;
- i = !flag && !flag1 && !flag2 ? -1 : 1;
- }
- }
- if(!flag)
- if(gridAlignment == 1)
- {
- int l = sampleScrollerBounds.x;
- int j1 = sampleScrollerBounds.x + sampleScrollerBounds.width;
- flag3 = k >= sampleScrollerBounds.y && k <= sampleScrollerBounds.y + sampleScrollerBounds.height;
- flag3 = flag3 && j >= l - 1 && j <= j1 + 1;
- insideLeftButton = flag3 && j >= l && j <= l + 8;
- insideRightButton = flag3 && j >= j1 - 8 && j <= j1;
- flag4 = flag3 && j >= leftAdjusterPos && j <= leftAdjusterPos + 2;
- flag5 = flag3 && j >= rightAdjusterPos - 2 && j <= rightAdjusterPos;
- flag3 = flag3 && j > leftAdjusterPos + 2 && j < rightAdjusterPos - 2;
- } else
- {
- int i1 = sampleScrollerBounds.y;
- int k1 = sampleScrollerBounds.y + sampleScrollerBounds.height;
- flag3 = j >= sampleScrollerBounds.x && j <= sampleScrollerBounds.x + sampleScrollerBounds.width;
- flag3 = flag3 && k >= i1 - 1 && k <= k1 + 1;
- insideLeftButton = flag3 && k >= i1 && k <= i1 + 8;
- insideRightButton = flag3 && k >= k1 - 8 && k <= k1;
- flag4 = flag3 && k >= leftAdjusterPos && k <= leftAdjusterPos + 2;
- flag5 = flag3 && k >= rightAdjusterPos - 2 && k <= rightAdjusterPos;
- flag3 = flag3 && k > leftAdjusterPos + 2 && k < rightAdjusterPos - 2;
- }
- switch(awtevent.getID())
- {
- case 504:
- case 505:
- default:
- break;
- case 503:
- if((flag1 || flag2) && flag)
- {
- setCursor(gridAlignment != 1 ? RESIZE_HOR_CURSOR : RESIZE_CURSOR);
- break;
- }
- if(flag)
- {
- setCursor(MOVE_CURSOR);
- break;
- }
- if(flag4 || flag5)
- {
- setCursor(gridAlignment != 1 ? RESIZE_CURSOR : RESIZE_HOR_CURSOR);
- break;
- }
- if(flag3)
- setCursor(MOVE_CURSOR);
- else
- setCursor(DEFAULT_CURSOR);
- break;
- case 501:
- adjustingUpper = flag1 && flag;
- adjustingLower = flag2 && flag;
- slidingAdjuster = flag && !flag1 && !flag2;
- adjusterIndex = i;
- leftPushed = insideLeftButton;
- rightPushed = insideRightButton;
- adjustingLeft = flag4;
- adjustingRight = flag5;
- slidingScroller = flag3 && !flag4 && !flag5;
- lastAdjusterClick = gridAlignment != 1 ? j : k;
- lastScrollerClick = gridAlignment != 1 ? k : j;
- long l1 = System.currentTimeMillis();
- int i2 = getSampleCount();
- if(insideLeftButton)
- {
- double d = (double)(chartDataBounds.width / i2) / (double)chartDataBounds.width;
- if(gridAlignment == 0)
- d = (double)(chartDataBounds.height / i2) / (double)chartDataBounds.height;
- d = Math.min(d, leftScrollerFactor);
- leftScrollerFactor -= d;
- rightScrollerFactor += d;
- if(scrollerThread == null)
- {
- scrollerThread = new Thread(this);
- scrollerThread.start();
- }
- } else
- if(insideRightButton)
- {
- double d1 = (double)(chartDataBounds.width / i2) / (double)chartDataBounds.width;
- if(gridAlignment == 0)
- d1 = (double)(chartDataBounds.height / i2) / (double)chartDataBounds.height;
- d1 = Math.min(d1, rightScrollerFactor);
- leftScrollerFactor += d1;
- rightScrollerFactor -= d1;
- if(scrollerThread == null)
- {
- scrollerThread = new Thread(this);
- scrollerThread.start();
- }
- } else
- if(flag3 && !insideLeftButton && !insideRightButton)
- {
- if(l1 - lastClickTime < 350L)
- {
- leftScrollerFactor = 0.0D;
- rightScrollerFactor = 0.0D;
- }
- } else
- if(flag && !flag1 && !flag2 && l1 - lastClickTime < 350L)
- {
- int j2 = 0;
- do
- {
- int l3 = rangeAdjusted[adjusterIndex] <= 1 ? rangeAdjusted[adjusterIndex] : j2;
- currentUpperRange[l3] = upperRange[l3];
- currentLowerRange[l3] = lowerRange[l3];
- for(int i4 = 0; i4 < overlayCharts.size(); i4++)
- {
- Chart chart = (Chart)overlayCharts.elementAt(i4);
- if(chart != null)
- {
- chart.currentUpperRange[l3] = chart.upperRange[l3];
- chart.currentLowerRange[l3] = chart.lowerRange[l3];
- }
- }
- } while(++j2 < 2);
- }
- lastClickTime = l1;
- hasChanged = true;
- repaint();
- break;
- case 506:
- int k2 = ((MouseEvent)awtevent).getY();
- if(gridAlignment == 0)
- k2 = ((MouseEvent)awtevent).getX();
- Rectangle rectangle = currentBounds;
- double d2 = 0.0D;
- if(adjustingUpper)
- {
- double d3;
- if(gridAlignment == 1)
- {
- setCursor(RESIZE_CURSOR);
- k2 -= rectangle.y;
- if(display3dOn && rangeAdjusterPosition[adjusterIndex] == 0)
- k2 += depth3dPoint.y;
- d3 = 1.0D - (double)k2 / (double)rectangle.height;
- } else
- {
- setCursor(RESIZE_HOR_CURSOR);
- k2 -= rectangle.x;
- if(display3dOn && rangeAdjusterPosition[adjusterIndex] == 0)
- k2 += depth3dPoint.x;
- d3 = (double)k2 / (double)rectangle.width;
- }
- if(rangeAdjusted[adjusterIndex] == 2)
- {
- int j4 = 0;
- do
- {
- adjustRange(this, j4, d3, 0.0D);
- for(int l6 = 0; l6 < overlayCharts.size(); l6++)
- adjustRange((Chart)overlayCharts.elementAt(l6), j4, d3, 0.0D);
- } while(++j4 < 2);
- } else
- {
- adjustRange(this, rangeAdjusted[adjusterIndex], d3, 0.0D);
- for(int k4 = 0; k4 < overlayCharts.size(); k4++)
- adjustRange((Chart)overlayCharts.elementAt(k4), rangeAdjusted[adjusterIndex], d3, 0.0D);
- }
- } else
- if(adjustingLower)
- {
- double d4;
- if(gridAlignment == 1)
- {
- setCursor(RESIZE_CURSOR);
- k2 -= rectangle.y;
- if(display3dOn && rangeAdjusterPosition[adjusterIndex] == 0)
- k2 += depth3dPoint.y;
- d4 = 1.0D - (double)k2 / (double)rectangle.height;
- } else
- {
- setCursor(RESIZE_HOR_CURSOR);
- k2 -= rectangle.x;
- if(display3dOn && rangeAdjusterPosition[adjusterIndex] == 0)
- k2 += depth3dPoint.x;
- d4 = (double)k2 / (double)rectangle.width;
- }
- if(rangeAdjusted[adjusterIndex] == 2)
- {
- int l4 = 0;
- do
- {
- adjustRange(this, l4, 0.0D, d4);
- for(int i7 = 0; i7 < overlayCharts.size(); i7++)
- adjustRange((Chart)overlayCharts.elementAt(i7), l4, 0.0D, d4);
- } while(++l4 < 2);
- } else
- {
- adjustRange(this, rangeAdjusted[adjusterIndex], 0.0D, d4);
- for(int i5 = 0; i5 < overlayCharts.size(); i5++)
- adjustRange((Chart)overlayCharts.elementAt(i5), rangeAdjusted[adjusterIndex], 0.0D, d4);
- }
- } else
- if(slidingAdjuster)
- {
- setCursor(MOVE_CURSOR);
- int j5 = lastAdjusterClick - k2;
- double d5;
- if(gridAlignment == 1)
- d5 = (double)j5 / (double)rectangle.height;
- else
- d5 = (double)j5 / (double)rectangle.width;
- if(rangeAdjusted[adjusterIndex] == 2)
- {
- int j7 = 0;
- do
- {
- adjustRangeSlide(this, j7, d5);
- for(int l7 = 0; l7 < overlayCharts.size(); l7++)
- adjustRangeSlide((Chart)overlayCharts.elementAt(l7), j7, d5);
- } while(++j7 < 2);
- } else
- {
- adjustRangeSlide(this, rangeAdjusted[adjusterIndex], d5);
- for(int k7 = 0; k7 < overlayCharts.size(); k7++)
- adjustRangeSlide((Chart)overlayCharts.elementAt(k7), rangeAdjusted[adjusterIndex], d5);
- }
- lastAdjusterClick = k2;
- } else
- if(adjustingLeft)
- {
- if(gridAlignment == 1)
- {
- int k5 = sampleScrollerBounds.x + 8;
- int l2 = Math.max(((MouseEvent)awtevent).getX(), k5);
- l2 = Math.min(l2, rightAdjusterPos - 8);
- leftScrollerFactor = (double)(l2 - k5) / (double)sampleScrollerSpace;
- } else
- {
- int l5 = sampleScrollerBounds.y + 8;
- int i3 = Math.max(((MouseEvent)awtevent).getY(), l5);
- i3 = Math.min(i3, rightAdjusterPos - 8);
- leftScrollerFactor = (double)(i3 - l5) / (double)sampleScrollerSpace;
- }
- } else
- if(adjustingRight)
- {
- if(gridAlignment == 1)
- {
- int i6 = sampleScrollerBounds.x + 8 + sampleScrollerSpace;
- int j3 = Math.min(((MouseEvent)awtevent).getX(), i6);
- j3 = Math.max(j3, leftAdjusterPos + 6);
- rightScrollerFactor = (double)(i6 - j3) / (double)sampleScrollerSpace;
- } else
- {
- int j6 = sampleScrollerBounds.y + 8 + sampleScrollerSpace;
- int k3 = Math.min(((MouseEvent)awtevent).getY(), j6);
- k3 = Math.max(k3, leftAdjusterPos + 6);
- rightScrollerFactor = (double)(j6 - k3) / (double)sampleScrollerSpace;
- }
- } else
- if(slidingScroller)
- {
- int k6 = gridAlignment != 1 ? k - lastScrollerClick : j - lastScrollerClick;
- double d6 = (double)k6 / (double)sampleScrollerSpace;
- if(k6 > 0)
- d6 = Math.min(d6, rightScrollerFactor);
- else
- d6 = -Math.min(-d6, leftScrollerFactor);
- leftScrollerFactor += d6;
- rightScrollerFactor -= d6;
- lastScrollerClick = gridAlignment != 1 ? k : j;
- }
- hasChanged = true;
- repaint();
- break;
- case 502:
- adjustingUpper = adjustingLower = slidingAdjuster = false;
- adjusterIndex = -1;
- leftPushed = rightPushed = false;
- adjustingLeft = adjustingRight = slidingScroller = false;
- if(scrollerThread != null)
- {
- scrollerThread.stop();
- scrollerThread = null;
- }
- hasChanged = true;
- repaint();
- break;
- }
- }
- void notifyListeners(Chart chart, int i, Object obj)
- {
- if(listeners != null)
- {
- ItemEvent itemevent = new ItemEvent(chart, 701, obj, i);
- for(Enumeration enumeration = listeners.elements(); enumeration.hasMoreElements(); ((ItemListener)enumeration.nextElement()).itemStateChanged(itemevent));
- }
- }
- public static final int HORIZONTAL = 0;
- public static final int VERTICAL = 1;
- public static final int LEFT = 0;
- public static final int RIGHT = 1;
- public static final int TOP = 2;
- public static final int BOTTOM = 3;
- public static final int TARGET_LINE_NO_LABEL = 0;
- public static final int TARGET_LINE_ID_LABEL = 1;
- public static final int TARGET_LINE_VALUE_LABEL = 2;
- public static final int TARGET_LINE_ID_AND_VALUE_LABEL = 3;
- static final int BELOW = 0;
- static final int FLOATING = 1;
- static final int BELOW_AND_FLOATING = 2;
- private static final int X_AXIS = 0;
- private static final int Y_AXIS = 1;
- protected ChartData chartData;
- protected Vector overlayCharts;
- private Color sampleColors[];
- private Color sampleLabelColors[];
- private Color seriesLabelColors[];
- private String chartTitle;
- private boolean chartTitleOn;
- private int sampleDecimalCount[];
- private boolean legendOn;
- private int legendPosition;
- private boolean valueLabelsOn[];
- private boolean display3dOn;
- private Color chartBackground;
- private Color chartForeground;
- private Hashtable labels;
- private Hashtable labelFonts;
- private Hashtable labelAngles;
- String legendLabels[];
- private Color legendColors[];
- private String legendImages[];
- private boolean automaticRepaintOn;
- private Insets graphInsets;
- private Dimension preferredSize;
- int lastSelectedSample;
- int lastSelectedSeries;
- boolean multiSeriesOn;
- int barLabelStyle;
- private boolean printAsBitmap;
- Hashtable images;
- private boolean overlayChartOn;
- private boolean servletModeOn;
- private boolean floatingOnLegendOn;
- boolean rangeOn[];
- double upperRange[];
- double lowerRange[];
- double currentUpperRange[];
- double currentLowerRange[];
- double leftSampleAxisRange;
- double rightSampleAxisRange;
- int rangePosition[];
- Color rangeColor[];
- int seriesRange[];
- boolean valueLinesOn;
- int maxValueLineCount;
- Color valueLinesColor;
- int maxGridLineCount;
- double gridLines[];
- double defaultGridLines[];
- Color defaultGridLinesColor;
- Color gridLineColors[];
- boolean rangeLabelsOn;
- int rangeDecimalCount[];
- boolean sampleLabelsOn;
- Hashtable targetsLabel;
- Hashtable targetsValue;
- Hashtable targetsColor;
- Hashtable targetsStyle;
- int zeroLine[];
- Point depth3dPoint;
- int depth3d;
- int gridAlignment;
- static final double STEPS[] = {
- 1.0D, 2D, 2.5D, 5D
- };
- static final float ANGLE = 1.25F;
- static final float DEPTH = 0.75F;
- Rectangle currentBounds;
- String barLabels[];
- boolean rangeAdjusterOn[];
- int rangeAdjusterPosition[];
- int rangeAdjusted[];
- boolean adjustingUpper;
- boolean adjustingLower;
- boolean slidingAdjuster;
- int adjusterIndex;
- int lastAdjusterClick;
- Rectangle rangeAdjusterBounds[];
- static Cursor RESIZE_CURSOR;
- static Cursor RESIZE_HOR_CURSOR;
- static Cursor MOVE_CURSOR;
- static Cursor DEFAULT_CURSOR;
- boolean sampleScrollerOn;
- boolean leftPushed;
- boolean rightPushed;
- boolean adjustingLeft;
- boolean adjustingRight;
- boolean slidingScroller;
- boolean insideLeftButton;
- boolean insideRightButton;
- int lastScrollerClick;
- double leftScrollerFactor;
- double rightScrollerFactor;
- int leftAdjusterPos;
- int rightAdjusterPos;
- int sampleScrollerSpace;
- Thread scrollerThread;
- Rectangle sampleScrollerBounds;
- Rectangle chartDataBounds;
- String chartType;
- Chart parentChart;
- private ChartSample selectedSample;
- Rectangle legendBounds[];
- boolean legendSelection[];
- private Vector listeners;
- private NumberFormat numberFormatter;
- boolean hasChanged;
- Rectangle legend;
- private long lastClickTime;
- private Image rotateImage;
- private Hashtable angledLabelCache;
- private Hashtable labelSizeCache;
- double valueLines[];
- Image offscreen;
- Graphics og;
- private long lastRenderTime;
- //private Chart2 c2;
- private static final int DOUBLE_CLICK_TIME = 350;
- MediaTracker imageTracker;
- boolean externalGraphicsOn;
- private static Color DEFAULT_SAMPLE_COLORS[] = {
- new Color(132, 130, 255), new Color(132, 32, 99), new Color(255, 255, 198), new Color(165, 227, 231), new Color(99, 0, 132), new Color(255, 130, 132), new Color(0, 130, 198), new Color(198, 195, 255), new Color(0, 0, 132), new Color(255, 0, 255),
- new Color(255, 255, 0), new Color(0, 255, 255), new Color(132, 0, 132), new Color(132, 0, 0), new Color(0, 130, 132), new Color(0, 0, 255), new Color(0, 207, 255), new Color(107, 255, 255), new Color(206, 255, 206), new Color(255, 255, 156)
- };
- }