public Object clone() { final Chart clone = (Chart) super.clone(); // Due to the not unique ID of the area component creating in JFreeChartEngine, we have to clear // all its children first. clone.getChildren().clear(); clone._smartDrawChartListener = null; clone._smartDrawChart = false; clone.init(); clone.doSmartDraw(); if (clone._model != null) { if (clone._model instanceof ComponentCloneListener) { final ChartModel model = (ChartModel) ((ComponentCloneListener) clone._model).willClone(clone); if (model != null) clone._model = model; } clone._dataListener = null; clone.initDataListener(); } return clone; }
private ChartModel createDefaultModel() { if (WAFERMAP.equals(getType())) { return new WaferMapModel(100, 100); } final String klass = DEFAULT_MODEL.get(getType()); if (klass != null) { try { return (ChartModel) Classes.newInstanceByThread(klass); } catch (Exception e) { throw UiException.Aide.wrap(e); } } else { throw new UiException("unknown chart type: " + getType()); } }
private void init() { if (_smartDrawChartListener == null) { _smartDrawChartListener = new SmartDrawListener(); addEventListener("onSmartDrawChart", _smartDrawChartListener); } }
/** * Set the pane color of the chart. * @param color in #RRGGBB format (hexadecimal). */ public void setPaneColor(String color) { if (Objects.equals(color, _paneColor)) { return; } _paneColor = color; if (_paneColor == null) { _paneRGB = null; } else { _paneRGB = new int[3]; decode(_paneColor, _paneRGB); } smartDrawChart(); }
public void render(Chart chart, Area area, ChartEntity info) { if (info instanceof LegendItemEntity) { area.setAttribute("entity", "LEGEND"); Integer seq = (Integer)chart.getAttribute("LEGEND_SEQ"); seq = seq == null ? new Integer(0) : new Integer(seq.intValue()+1); chart.setAttribute("LEGEND_SEQ", seq); decodeLegendInfo(area, (LegendItemEntity)info, chart); } else { area.setAttribute("entity", "TITLE"); if (chart.isShowTooltiptext()) { area.setTooltiptext(chart.getTitle()); } } } public JFreeChart createChart(Chart chart) {
float alpha = (float)(((float)chart.getFgAlpha()) / 255); plot.setForegroundAlpha(alpha); alpha = (float)(((float)chart.getBgAlpha()) / 255); plot.setBackgroundAlpha(alpha); int[] bgRGB = chart.getBgRGB(); if (bgRGB != null) { plot.setBackgroundPaint(new Color(bgRGB[0], bgRGB[1], bgRGB[2], chart.getBgAlpha())); int[] paneRGB = chart.getPaneRGB(); if (paneRGB != null) { jfchart.setBackgroundPaint(new Color(paneRGB[0], paneRGB[1], paneRGB[2], chart.getPaneAlpha())); final Font tfont = chart.getTitleFont(); if (tfont != null) { jfchart.getTitle().setFont(tfont); final Font lfont = chart.getLegendFont(); if (lfont != null) { jfchart.getLegend().setItemFont(lfont); final Font xlbfont = chart.getXAxisFont(); if (xlbfont != null) { pplot.setLabelFont(xlbfont); final Font xlbfont = chart.getXAxisFont(); final Font xtkfont = chart.getXAxisTickFont(); if (xlbfont != null) {
private void doSmartDraw() { if (Strings.isBlank(getType())) throw new UiException("chart must specify type (pie, bar, line, ...)"); if (_model == null) { _model = createDefaultModel(); } if (Strings.isBlank(getWidth())) throw new UiException("chart must specify width"); if (Strings.isBlank(getHeight())) throw new UiException("chart must specify height"); try { final AImage image = new AImage("chart" + new Date().getTime(), getEngine().drawChart(Chart.this)); setContent(image); } catch (java.io.IOException ex) { throw UiException.Aide.wrap(ex); } finally { _smartDrawChart = false; } }
if (Objects.equals(chart.getType(), _type) && _threeD == chart.isThreeD()) { return _chartImpl; if (Chart.PIE.equals(chart.getType())) _chartImpl = chart.isThreeD() ? new Pie3d() : new Pie(); else if (Chart.RING.equals(chart.getType())) _chartImpl = new Ring(); else if (Chart.BAR.equals(chart.getType())) _chartImpl = chart.isThreeD() ? new Bar3d() : new Bar(); else if (Chart.LINE.equals(chart.getType())) _chartImpl = chart.isThreeD() ? new Line3d() : new Line(); else if (Chart.AREA.equals(chart.getType())) _chartImpl = new AreaImpl(); else if (Chart.STACKED_BAR.equals(chart.getType())) _chartImpl = chart.isThreeD() ? new StackedBar3d() : new StackedBar(); else if (Chart.STACKED_AREA.equals(chart.getType())) _chartImpl = new StackedArea(); else if (Chart.WATERFALL.equals(chart.getType())) _chartImpl = new Waterfall(); else if (Chart.POLAR.equals(chart.getType())) _chartImpl = new Polar();
/** * decode TickLabelEntity into key-value pair of Area's componentScope. * @param area the Area where the final attribute is set * @param info the TickLabelEntity to be decoded. */ private void decodeTickLabelInfo(Area area, TickLabelEntity info, Chart chart) { if (info == null) { return; } final ChartModel model = chart.getModel(); final int seq = ((Integer)chart.getAttribute("TICK_SEQ")).intValue(); if (model instanceof CategoryModel) { Comparable category = ((CategoryModel)model).getCategory(seq); area.setAttribute("category", category); if (chart.isShowTooltiptext() && info.getToolTipText() == null) { area.setTooltiptext(category.toString()); } } }
/** * Set the range color of the dial range. * @param color in #RRGGBB format (hexadecimal). */ public void setRangeColor(String color) { if (Objects.equals(color, _color)) { return; } _color = color; if (_color == null) { _RGB = null; } else { _RGB = new int[3]; Chart.decode(_color, _RGB); } _scale.fireEvent(ChartDataEvent.CHANGED, DialChartDataEvent.RANGE_COLOR, color); }
public void render(Chart chart, Area area, ChartEntity info) { // System.out.println("wind info:"+info); if (info instanceof LegendItemEntity) { area.setAttribute("entity", "LEGEND"); Integer seq = (Integer)chart.getAttribute("LEGEND_SEQ"); seq = seq == null ? new Integer(0) : new Integer(seq.intValue()+1); chart.setAttribute("LEGEND_SEQ", seq); decodeLegendInfo(area, (LegendItemEntity)info, chart); } else { area.setAttribute("entity", "TITLE"); if (chart.isShowTooltiptext()) { area.setTooltiptext(chart.getTitle()); } } } public JFreeChart createChart(Chart chart) {
return; final ChartModel model = chart.getModel(); final int seq = ((Integer)chart.getAttribute("LEGEND_SEQ")).intValue(); area.setAttribute("category", category); area.setAttribute("value", ((PieModel)model).getValue(category)); if (chart.isShowTooltiptext() && info.getToolTipText() == null) { area.setTooltiptext(category.toString()); Comparable series = ((CategoryModel)model).getSeries(seq); area.setAttribute("series", series); if (chart.isShowTooltiptext() && info.getToolTipText() == null) { area.setTooltiptext(series.toString()); Comparable series = ((XYModel)model).getSeries(seq); area.setAttribute("series", series); if (chart.isShowTooltiptext() && info.getToolTipText() == null) { area.setTooltiptext(series.toString()); if (chart.isShowTooltiptext() && info.getToolTipText() == null) { area.setTooltiptext(series.toString()); final Comparable series = info.getSeriesKey(); area.setAttribute("series", series); if (chart.isShowTooltiptext() && info.getToolTipText() == null) { area.setTooltiptext(series.toString());
/** * Set the background color of the chart. * @param color in #RRGGBB format (hexadecimal). */ public void setBgColor(String color) { if (Objects.equals(color, _bgColor)) { return; } _bgColor = color; if (_bgColor == null) { _bgRGB = null; } else { _bgRGB = new int[3]; decode(_bgColor, _bgRGB); } smartDrawChart(); }
/** * Set the foreground color of the dial frame. * @param color in #RRGGBB format (hexadecimal). */ public void setFrameFgColor(String color) { if (Objects.equals(color, _fgColor)) { return; } _fgColor = color; if (_fgColor == null) { _fgRGB = null; } else { _fgRGB = new int[3]; Chart.decode(_fgColor, _fgRGB); } fireEvent(ChartDataEvent.CHANGED, DialChartDataEvent.FRAME_FG_COLOR, color); }
public void render(Chart chart, Area area, ChartEntity info) { if (info instanceof LegendItemEntity) { area.setAttribute("entity", "LEGEND"); Integer seq = (Integer)chart.getAttribute("LEGEND_SEQ"); seq = seq == null ? new Integer(0) : new Integer(seq.intValue()+1); chart.setAttribute("LEGEND_SEQ", seq); decodeLegendInfo(area, (LegendItemEntity)info, chart); } else if (info instanceof XYItemEntity) { area.setAttribute("entity", "DATA"); decodeXYInfo(area, (XYItemEntity)info, chart); } else { area.setAttribute("entity", "TITLE"); if (chart.isShowTooltiptext()) { area.setTooltiptext(chart.getTitle()); } } } public JFreeChart createChart(Chart chart) {
/** * Set the 2nd background color of the dial frame (for gradient ending color). * @param color in #RRGGBB format (hexadecimal). */ public void setFrameBgColor2(String color) { if (Objects.equals(color, _bgColor2)) { return; } _bgColor2 = color; if (_bgColor2 == null) { _bgRGB2 = null; } else { _bgRGB2 = new int[3]; Chart.decode(_bgColor2, _bgRGB2); } fireEvent(ChartDataEvent.CHANGED, DialChartDataEvent.FRAME_BG_COLOR_2, color); }
public void render(Chart chart, Area area, ChartEntity info) { if (info instanceof LegendItemEntity) { area.setAttribute("entity", "LEGEND"); Integer seq = (Integer)chart.getAttribute("LEGEND_SEQ"); seq = seq == null ? new Integer(0) : new Integer(seq.intValue()+1); chart.setAttribute("LEGEND_SEQ", seq); decodeLegendInfo(area, (LegendItemEntity)info, chart); } else if (info instanceof PieSectionEntity) { area.setAttribute("entity", "DATA"); decodePieInfo(area, (PieSectionEntity)info); } else { area.setAttribute("entity", "TITLE"); if (chart.isShowTooltiptext()) { area.setTooltiptext(chart.getTitle()); } } }
/** * Set the tick color. * @param color in #RRGGBB format (hexadecimal). */ public void setTickColor(String color) { if (Objects.equals(color, _tickColor)) { return; } _tickColor = color; if (_tickColor == null) { _tickRGB = null; } else { _tickRGB = new int[3]; Chart.decode(_tickColor, _tickRGB); } fireEvent(ChartDataEvent.CHANGED, DialChartDataEvent.TICK_COLOR, color); }
public void render(Chart chart, Area area, ChartEntity info) { if (info instanceof LegendItemEntity) { area.setAttribute("entity", "LEGEND"); Integer seq = (Integer)chart.getAttribute("LEGEND_SEQ"); seq = seq == null ? new Integer(0) : new Integer(seq.intValue()+1); chart.setAttribute("LEGEND_SEQ", seq); decodeLegendInfo(area, (LegendItemEntity)info, chart); } else if (info instanceof XYItemEntity) { area.setAttribute("entity", "DATA"); decodeXYInfo(area, (XYItemEntity)info, chart); } else { area.setAttribute("entity", "TITLE"); if (chart.isShowTooltiptext()) { area.setTooltiptext(chart.getTitle()); } } } public JFreeChart createChart(Chart chart) {
/** * Set the background color of the dial frame. * @param color in #RRGGBB format (hexadecimal). */ public void setFrameBgColor(String color) { if (Objects.equals(color, _bgColor)) { return; } _bgColor = color; if (_bgColor == null) { _bgRGB = null; } else { _bgRGB = new int[3]; Chart.decode(_bgColor, _bgRGB); } fireEvent(ChartDataEvent.CHANGED, DialChartDataEvent.FRAME_BG_COLOR, color); }