protected void setDialPointer(ChartDocument chartDocument, DialPlot dialPlot) { // ~ params begin double pointerRadius = 0.9; // length of pointer double pointerWidthRadius = 0.05; // width of base of pointer Color pointerFillPaint = Color.gray; Color pointerOutlinePaint = Color.black; Stroke pointerOutlineStroke = new BasicStroke(2.0f); // ~ params end VariableStrokePointer pointer = new VariableStrokePointer(); ChartElement pointerElement = getUniqueElement(chartDocument, DIALPOINTER); final Color pointerColorTmp = ColorFactory.getInstance().getColor(pointerElement); if (pointerColorTmp != null) { pointerFillPaint = pointerColorTmp; } final Color pointerBorderColorTmp = ColorFactory.getInstance().getColor(pointerElement, BorderStyleKeys.BORDER_TOP_COLOR); if (pointerBorderColorTmp != null) { pointerOutlinePaint = pointerBorderColorTmp; } double pointerWidthRadiusTmp = parseDouble(pointerElement.getLayoutStyle().getValue(BoxStyleKeys.WIDTH)) / 100; if (pointerWidthRadiusTmp != 0) { pointerWidthRadius = pointerWidthRadiusTmp; } double pointerRadiusTmp = parseDouble(pointerElement.getLayoutStyle().getValue(BoxStyleKeys.HEIGHT)) / 100; if (pointerRadiusTmp != 0) { pointerRadius = pointerRadiusTmp; } final BasicStroke borderStyleStroke = StrokeFactory.getInstance().getBorderStroke(pointerElement); if (borderStyleStroke != null) { pointerOutlineStroke = borderStyleStroke; } pointer.setRadius(pointerRadius); pointer.setOutlineStroke(pointerOutlineStroke); pointer.setWidthRadius(pointerWidthRadius); pointer.setFillPaint(pointerFillPaint); pointer.setOutlinePaint(pointerOutlinePaint); // DialPointer pointer = new DialPointer.Pin(); dialPlot.addPointer(pointer); }
protected void setDialFrame(ChartDocument chartDocument, DialPlot dialPlot) { // ~ params begin Color frameForegroundPaint = Color.black; Color frameInnerForegroundPaint = Color.black; Color frameBackgroundPaint = Color.white; Stroke frameStroke = new BasicStroke(2.0f); // ~ params end final StrokeFactory strokeFacObj = StrokeFactory.getInstance(); ChartElement plotElement = getUniqueElement(chartDocument, ChartElement.TAG_NAME_PLOT); final BasicStroke borderStyleStroke = strokeFacObj.getBorderStroke(plotElement); if (borderStyleStroke != null) { frameStroke = borderStyleStroke; } final Color outerBorderColor = ColorFactory.getInstance().getColor(plotElement, BorderStyleKeys.BORDER_TOP_COLOR); if (outerBorderColor != null) { frameForegroundPaint = outerBorderColor; } final Color innerBorderColorTmp = ColorFactory.getInstance().getColor(plotElement, BorderStyleKeys.BORDER_BOTTOM_COLOR); if (innerBorderColorTmp != null) { frameInnerForegroundPaint = innerBorderColorTmp; } final Color borderBackgroundColorTmp = ColorFactory.getInstance().getColor(plotElement); if (borderBackgroundColorTmp != null) { frameBackgroundPaint = borderBackgroundColorTmp; } final DoubleLineDialFrame dialFrame = new DoubleLineDialFrame(); dialFrame.setForegroundPaint(frameForegroundPaint); dialFrame.setInnerForegroundPaint(frameInnerForegroundPaint); dialFrame.setStroke(frameStroke); dialFrame.setBackgroundPaint(frameBackgroundPaint); dialPlot.setDialFrame(dialFrame); }
protected void setDialCap(ChartDocument chartDocument, DialPlot dialPlot) { // ~ params begin double capRadius = 0.05; // expressed as percentage of dial's framing rectangle Color capFillPaint = Color.white; Color capOutlinePaint = Color.black; Stroke capOutlineStroke = new BasicStroke(2.0f); // ~ params end final StrokeFactory strokeFacObj = StrokeFactory.getInstance(); ChartElement dialCapElement = getUniqueElement(chartDocument, DIALCAP); final BasicStroke borderStyleStroke = strokeFacObj.getBorderStroke(dialCapElement); if (borderStyleStroke != null) { capOutlineStroke = borderStyleStroke; } final Color borderColor = ColorFactory.getInstance().getColor(dialCapElement, BorderStyleKeys.BORDER_TOP_COLOR); if (borderColor != null) { capOutlinePaint = borderColor; } final Color capColor = ColorFactory.getInstance().getColor(dialCapElement); if (capColor != null) { capFillPaint = capColor; } capRadius = parseDouble(dialCapElement.getLayoutStyle().getValue(BoxStyleKeys.WIDTH)) / 100; DialCap dialCap = new DialCap(); dialCap.setRadius(capRadius); dialCap.setFillPaint(capFillPaint); dialCap.setOutlinePaint(capOutlinePaint); dialCap.setOutlineStroke(capOutlineStroke); dialPlot.setCap(dialCap); }
public void setDialValueIndicator(ChartDocument chartDocument, DialPlot dialPlot) { // ~ params begin Font valueIndicatorFont = new Font("Dialog", Font.BOLD, 14); // $NON-NLS-1$ Color valueIndicatorPaint = Color.black; Color valueIndicatorBackgroundPaint = Color.white; Stroke valueIndicatorOutlineStroke = new BasicStroke(1.0f); Color valueIndicatorOutlinePaint = Color.blue; // ~ params end ChartElement valIndicatorElement = getUniqueElement(chartDocument, DIALVALUEINDICATOR); Color valIndicatorColorTmp = ColorFactory.getInstance().getColor(valIndicatorElement); if (valIndicatorColorTmp != null) { valueIndicatorPaint = valIndicatorColorTmp; } Color valIndicatorBgColorTmp = ColorFactory.getInstance().getColor(valIndicatorElement, BorderStyleKeys.BACKGROUND_COLOR); if (valIndicatorBgColorTmp != null) { valueIndicatorBackgroundPaint = valIndicatorBgColorTmp; } final BasicStroke borderStyleStroke = StrokeFactory.getInstance().getBorderStroke(valIndicatorElement); if (borderStyleStroke != null) { valueIndicatorOutlineStroke = borderStyleStroke; } Color valIndicatorBorderColorTmp = ColorFactory.getInstance().getColor(valIndicatorElement, BorderStyleKeys.BORDER_TOP_COLOR); if (valIndicatorBorderColorTmp != null) { valueIndicatorOutlinePaint = valIndicatorBorderColorTmp; } Font valIndicatorFontTmp = JFreeChartUtils.getFont(valIndicatorElement); if (valIndicatorFontTmp != null) { valueIndicatorFont = valIndicatorFontTmp; } DialValueIndicator dialValueIndicator = new DialValueIndicator(0); // begin code to determine the size of the value indicator box ChartElement scaleElement = getUniqueElement(chartDocument, SCALE); if (scaleElement != null) { double scaleUpperBound = Double.parseDouble(scaleElement.getAttribute(UPPERBOUND).toString()); double scaleLowerBound = Double.parseDouble(scaleElement.getAttribute(LOWERBOUND).toString()); if (Math.abs(scaleUpperBound) > Math.abs(scaleLowerBound)) { dialValueIndicator.setTemplateValue(scaleUpperBound); } else { dialValueIndicator.setTemplateValue(scaleLowerBound); } } // end code to determine the size of the value indicator box dialValueIndicator.setFont(valueIndicatorFont); dialValueIndicator.setPaint(valueIndicatorPaint); dialValueIndicator.setBackgroundPaint(valueIndicatorBackgroundPaint); dialValueIndicator.setOutlineStroke(valueIndicatorOutlineStroke); dialValueIndicator.setOutlinePaint(valueIndicatorOutlinePaint); dialPlot.addLayer(dialValueIndicator); }