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 setDialTextAnnotation(ChartDocument chartDocument, DialPlot dialPlot) { // ~ params begin Font textAnnotationFont = new Font("Dialog", Font.BOLD, 14); // $NON-NLS-1$ Color textAnnotationPaint = Color.black; final double textAnnotationRadius = 0.69999999999999996D; // hard-coded for now // ~ params end ChartElement annotationElement = getUniqueElement(chartDocument, ANNOTATION); if (annotationElement != null && annotationElement.getText() != null) { String annotation = annotationElement.getText(); Color annotationColorTmp = ColorFactory.getInstance().getColor(annotationElement); if (annotationColorTmp != null) { textAnnotationPaint = annotationColorTmp; } Font annotationFontTmp = JFreeChartUtils.getFont(annotationElement); if (annotationFontTmp != null) { textAnnotationFont = annotationFontTmp; } DialTextAnnotation dialtextannotation = new DialTextAnnotation(annotation); dialtextannotation.setFont(textAnnotationFont); dialtextannotation.setPaint(textAnnotationPaint); dialtextannotation.setRadius(textAnnotationRadius); dialPlot.addLayer(dialtextannotation); } }
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); }
protected void setDialRange(ChartDocument chartDocument, DialPlot dialPlot) { final double rangeInnerRadius = 0.4D; ChartElement[] rangeElements = getElements(chartDocument, DIALRANGE); for (int i = 0; i < rangeElements.length; i++) { double lowerBound = Double.parseDouble(rangeElements[i].getAttribute(LOWERBOUND).toString()); double upperBound = Double.parseDouble(rangeElements[i].getAttribute(UPPERBOUND).toString()); final Color rangeColorTmp = ColorFactory.getInstance().getColor(rangeElements[i]); Color rangeColor = Color.BLACK; if (rangeColorTmp != null) { rangeColor = rangeColorTmp; } SingleLineDialRange standarddialrange = new SingleLineDialRange(lowerBound, upperBound, rangeColor); standarddialrange.setInnerRadius(rangeInnerRadius); dialPlot.addLayer(standarddialrange); } }
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); }
protected void setDialScale(ChartDocument chartDocument, DialPlot dialPlot) { // ~ params begin double scaleLowerBound = -40D; double scaleUpperBound = 60D; double scaleStartAngle = -120D; double scaleExtent = -300D; double scaleMajorTickIncrement = 10D; int scaleMinorTickCount = 4; final double scaleTickRadius = 0.88D; final double scaleTickLabelOffset = 0.14999999999999999D; double scaleMajorTickLength = 0.04; Color scaleMajorTickPaint = Color.black; Stroke scaleMajorTickStroke = new BasicStroke(3.0f); double scaleMinorTickLength = 0.02; Color scaleMinorTickPaint = Color.black; Stroke scaleMinorTickStroke = new BasicStroke(1.0f); Font scaleTickLabelFont = new Font("Dialog", 0, 14); // $NON-NLS-1$ Color scaleTickLabelPaint = Color.blue; // ~ params end ChartElement scaleElement = getUniqueElement(chartDocument, SCALE); scaleUpperBound = Double.parseDouble(scaleElement.getAttribute(UPPERBOUND).toString()); scaleLowerBound = Double.parseDouble(scaleElement.getAttribute(LOWERBOUND).toString()); scaleStartAngle = Double.parseDouble(scaleElement.getAttribute(STARTANGLE).toString()); scaleExtent = Double.parseDouble(scaleElement.getAttribute(EXTENT).toString()); ChartElement tickLabelElement = getUniqueElement(chartDocument, TICKLABEL); Color tickLabelColorTmp = ColorFactory.getInstance().getColor(tickLabelElement); if (tickLabelColorTmp != null) { scaleTickLabelPaint = tickLabelColorTmp; } Font tickLabelFontTmp = JFreeChartUtils.getFont(tickLabelElement); if (tickLabelFontTmp != null) { scaleTickLabelFont = tickLabelFontTmp; } ChartElement majorTickElement = getUniqueElement(chartDocument, MAJORTICK); scaleMajorTickIncrement = Double.parseDouble((String) majorTickElement.getAttribute(INCREMENT)); float majorTickWidthTmp = (float) parseDouble(majorTickElement.getLayoutStyle().getValue(BoxStyleKeys.WIDTH)); if (majorTickWidthTmp != 0) { scaleMajorTickStroke = new BasicStroke(majorTickWidthTmp); } double majorTickLengthTmp = parseDouble(majorTickElement.getLayoutStyle().getValue(BoxStyleKeys.HEIGHT)) / 100; if (majorTickLengthTmp != 0) { scaleMajorTickLength = majorTickLengthTmp; } ChartElement minorTickElement = getUniqueElement(chartDocument, MINORTICK); scaleMinorTickCount = Integer.parseInt((String) minorTickElement.getAttribute(COUNT)); float minorTickWidthTmp = (float) parseDouble(minorTickElement.getLayoutStyle().getValue(BoxStyleKeys.WIDTH)); if (minorTickWidthTmp != 0) { scaleMinorTickStroke = new BasicStroke(minorTickWidthTmp); } double minorTickLengthTmp = parseDouble(minorTickElement.getLayoutStyle().getValue(BoxStyleKeys.HEIGHT)) / 100; if (minorTickLengthTmp != 0) { scaleMinorTickLength = minorTickLengthTmp; } Color majorTickColorTmp = ColorFactory.getInstance().getColor(majorTickElement); if (majorTickColorTmp != null) { scaleMajorTickPaint = majorTickColorTmp; } Color minorTickColorTmp = ColorFactory.getInstance().getColor(minorTickElement); if (minorTickColorTmp != null) { scaleMinorTickPaint = minorTickColorTmp; } FixedStandardDialScale standardDialScale = new FixedStandardDialScale( scaleLowerBound, scaleUpperBound, scaleStartAngle, scaleExtent, scaleMajorTickIncrement, scaleMinorTickCount); standardDialScale.setTickRadius(scaleTickRadius); standardDialScale.setTickLabelOffset(scaleTickLabelOffset); standardDialScale.setTickLabelFont(scaleTickLabelFont); standardDialScale.setTickLabelPaint(scaleTickLabelPaint); standardDialScale.setMajorTickLength(scaleMajorTickLength); standardDialScale.setMajorTickPaint(scaleMajorTickPaint); standardDialScale.setMajorTickStroke(scaleMajorTickStroke); standardDialScale.setMinorTickLength(scaleMinorTickLength); standardDialScale.setMinorTickPaint(scaleMinorTickPaint); standardDialScale.setMinorTickStroke(scaleMinorTickStroke); dialPlot.addScale(0, standardDialScale); }