diff --git a/src/snapcharts/app/ChartStyler.java b/src/snapcharts/app/ChartStyler.java index ddfe353..4a1bbcc 100644 --- a/src/snapcharts/app/ChartStyler.java +++ b/src/snapcharts/app/ChartStyler.java @@ -4,7 +4,6 @@ import snap.util.Undoer; import snap.view.View; import snapcharts.model.ChartPart; -import snapcharts.model.Trace; /** * ChartStyler. @@ -138,10 +137,7 @@ public void setTextColor(Color aColor) */ private ChartPart getSelPart() { - ChartPart chartPart = _editor.getSelChartPart(); - if (chartPart instanceof Trace) - chartPart = ((Trace) chartPart).getTraceStyle(); - return chartPart; + return _editor.getSelChartPart(); } /** diff --git a/src/snapcharts/appmisc/OpenInPlotly.java b/src/snapcharts/appmisc/OpenInPlotly.java index 37061f9..d2b8fdf 100644 --- a/src/snapcharts/appmisc/OpenInPlotly.java +++ b/src/snapcharts/appmisc/OpenInPlotly.java @@ -270,7 +270,6 @@ else if (axis.isZeroRequired()) private void writeTrace(Trace aTrace, int anIndex) { // Get Trace info - TraceStyle traceStyle = aTrace.getTraceStyle(); int pointCount = aTrace.getPointCount(); DataType dataType = aTrace.getDataType(); int chanCount = dataType.getChannelCount(); @@ -324,12 +323,12 @@ private void writeTrace(Trace aTrace, int anIndex) traceJS.addKeyValue("line", lineJS); // Set the line.color - Color color = traceStyle.getLineColor(); + Color color = aTrace.getLineColor(); String colorStr = getPlotlyColorString(color); lineJS.addKeyValue("color", colorStr); // Set the line.width - lineJS.addKeyValue("width", traceStyle.getLineWidth()); + lineJS.addKeyValue("width", aTrace.getLineWidth()); } } diff --git a/src/snapcharts/apptools/ContourStyleInsp.java b/src/snapcharts/apptools/ContourStyleInsp.java index 2d18e3b..eea590c 100644 --- a/src/snapcharts/apptools/ContourStyleInsp.java +++ b/src/snapcharts/apptools/ContourStyleInsp.java @@ -2,6 +2,7 @@ import snap.view.ViewEvent; import snapcharts.app.ChartPane; import snapcharts.model.ChartPart; +import snapcharts.model.Trace; import snapcharts.model.TraceStyle; import snapcharts.modelx.ContourStyle; @@ -28,17 +29,34 @@ public ContourStyleInsp(ChartPane aChartPane) * Returns the ChartPart. */ @Override - public ChartPart getChartPart() { return getChart().getTraceStyle(); } + public ChartPart getChartPart() { return getContourStyle(); } + + /** + * Returns the Trace. + */ + public Trace getTrace() + { + ChartPart selPart = _chartPane.getSelChartPart(); + return selPart instanceof Trace ? (Trace) selPart : null; + } + + /** + * Returns the TraceStyle. + */ + public ContourStyle getContourStyle() + { + Trace trace = getTrace(); + TraceStyle traceStyle = trace != null ? trace.getTraceStyle() : null; + return traceStyle instanceof ContourStyle ? (ContourStyle) traceStyle : null; + } /** * Reset UI. */ protected void resetUI() { - // Get TraceStyle - TraceStyle traceStyle = getChart().getTraceStyle(); - ContourStyle contourStyle = traceStyle instanceof ContourStyle ? (ContourStyle) traceStyle : null; - if (contourStyle == null) return; + // Get ContourStyle + ContourStyle contourStyle = getContourStyle(); if (contourStyle == null) return; // Reset ShowLinesCheckBox, ShowMeshCheckBox setViewValue("ShowLinesCheckBox", contourStyle.isShowLines()); @@ -51,10 +69,8 @@ protected void resetUI() */ protected void respondUI(ViewEvent anEvent) { - // Get TraceStyle - TraceStyle traceStyle = getChart().getTraceStyle(); - ContourStyle contourStyle = traceStyle instanceof ContourStyle ? (ContourStyle) traceStyle : null; - if (contourStyle == null) return; + // Get ContourStyle + ContourStyle contourStyle = getContourStyle(); if (contourStyle == null) return; // Handle ShowLinesCheckBox, ShowMeshCheckBox if (anEvent.equals("ShowLinesCheckBox")) diff --git a/src/snapcharts/apptools/PolarStyleInsp.java b/src/snapcharts/apptools/PolarStyleInsp.java index d992475..5c07e13 100644 --- a/src/snapcharts/apptools/PolarStyleInsp.java +++ b/src/snapcharts/apptools/PolarStyleInsp.java @@ -4,7 +4,6 @@ package snapcharts.apptools; import snap.view.ViewEvent; import snapcharts.app.ChartPane; -import snapcharts.model.Chart; import snapcharts.model.ChartPart; import snapcharts.model.Trace; import snapcharts.model.TraceStyle; @@ -33,34 +32,25 @@ public PolarStyleInsp(ChartPane aChartPane) * Returns the ChartPart. */ @Override - public ChartPart getChartPart() { return getChart().getTraceStyle(); } + public ChartPart getChartPart() { return getPolarStyle(); } /** - * Returns the PolarStyle. + * Returns the Trace. */ - public PolarStyle getPolarStyle() + public Trace getTrace() { - ChartPart chartPart = _chartPane.getSelChartPart(); - if (chartPart instanceof Trace) { - Trace trace = (Trace) chartPart; - TraceStyle traceStyle = trace.getTraceStyle(); - if (traceStyle instanceof PolarStyle) - return (PolarStyle) traceStyle; - } - - Chart chart = getChart(); - TraceStyle traceStyle = chart.getTraceStyle(); - if (traceStyle instanceof PolarStyle) - return (PolarStyle) traceStyle; - return null; + ChartPart selPart = _chartPane.getSelChartPart(); + return selPart instanceof Trace ? (Trace) selPart : null; } /** - * Initialize UI. + * Returns the PolarStyle. */ - @Override - protected void initUI() + public PolarStyle getPolarStyle() { + Trace trace = getTrace(); + TraceStyle traceStyle = trace != null ? trace.getTraceStyle() : null; + return traceStyle instanceof PolarStyle ? (PolarStyle) traceStyle : null; } /** diff --git a/src/snapcharts/apptools/TraceAreaStyleInsp.java b/src/snapcharts/apptools/TraceAreaStyleInsp.java index 9f9c487..27da3f3 100644 --- a/src/snapcharts/apptools/TraceAreaStyleInsp.java +++ b/src/snapcharts/apptools/TraceAreaStyleInsp.java @@ -33,7 +33,7 @@ public TraceAreaStyleInsp(ChartPane aChartPane) @Override public ChartPart getChartPart() { - return getTraceStyle(); + return getTrace(); } /** @@ -45,18 +45,6 @@ public Trace getTrace() return selPart instanceof Trace ? (Trace) selPart : null; } - /** - * Returns the TraceStyle. - */ - public TraceStyle getTraceStyle() - { - Trace trace = getTrace(); - if (trace != null) - return trace.getTraceStyle(); - - return getChart().getTraceStyle(); - } - /** * Initialize UI. */ @@ -64,8 +52,8 @@ public TraceStyle getTraceStyle() protected void initUI() { // Configure FillModeComboBox to show FillModes - ComboBox fillModeComboBox = getView("FillModeComboBox", ComboBox.class); - fillModeComboBox.setItems(TraceStyle.FillMode.values()); + ComboBox fillModeComboBox = getView("FillModeComboBox", ComboBox.class); + fillModeComboBox.setItems(Trace.FillMode.values()); fillModeComboBox.setItemTextFunction(item -> StringUtils.fromCamelCase(item.toString())); } @@ -74,20 +62,19 @@ protected void initUI() */ protected void resetUI() { - // Get Trace, TraceStyle + // Get Trace Trace trace = getTrace(); if (trace == null) return; - TraceStyle traceStyle = getTraceStyle(); if (traceStyle == null) return; // Reset ShowAreaCheckBox boolean showArea = trace.isShowArea(); setViewValue("ShowAreaCheckBox", showArea); // Reset FillColorButton, FillColorResetButton - setViewValue("FillColorButton", traceStyle.getFillColor()); - setViewVisible("FillColorResetButton", traceStyle.isFillSet()); + setViewValue("FillColorButton", trace.getFillColor()); + setViewVisible("FillColorResetButton", trace.isFillSet()); // Reset FillModeComboBox - setViewSelItem("FillModeComboBox", traceStyle.getFillMode()); + setViewSelItem("FillModeComboBox", trace.getFillMode()); } /** @@ -95,9 +82,8 @@ protected void resetUI() */ protected void respondUI(ViewEvent anEvent) { - // Get TraceStyle + // Get Trace Trace trace = getTrace(); if (trace == null) return; - TraceStyle traceStyle = getTraceStyle(); if (traceStyle == null) return; // Handle ShowAreaCheckBox, FillModeComboBox if (anEvent.equals("ShowAreaCheckBox")) { @@ -109,15 +95,15 @@ protected void respondUI(ViewEvent anEvent) if (anEvent.equals("FillColorButton")) { Color color = (Color) getViewValue("FillColorButton"); color = color.getAlpha() <= .5 ? color : color.copyForAlpha(.5); - traceStyle.setFill(color); + trace.setFill(color); } if (anEvent.equals("FillColorResetButton")) - traceStyle.setFill(null); + trace.setFill(null); // Handle FillModeComboBox if (anEvent.equals("FillModeComboBox")) { - TraceStyle.FillMode fillMode = (TraceStyle.FillMode) getViewSelItem("FillModeComboBox"); - traceStyle.setFillMode(fillMode); + Trace.FillMode fillMode = (Trace.FillMode) getViewSelItem("FillModeComboBox"); + trace.setFillMode(fillMode); } } } \ No newline at end of file diff --git a/src/snapcharts/apptools/TraceLineStyleInsp.java b/src/snapcharts/apptools/TraceLineStyleInsp.java index 4c6cdef..cb2da97 100644 --- a/src/snapcharts/apptools/TraceLineStyleInsp.java +++ b/src/snapcharts/apptools/TraceLineStyleInsp.java @@ -37,7 +37,7 @@ public TraceLineStyleInsp(ChartPane aChartPane) @Override public ChartPart getChartPart() { - return getTraceStyle(); + return getTrace(); } /** @@ -49,18 +49,6 @@ public Trace getTrace() return selPart instanceof Trace ? (Trace) selPart : null; } - /** - * Returns the TraceStyle. - */ - public TraceStyle getTraceStyle() - { - Trace trace = getTrace(); - if (trace != null) - return trace.getTraceStyle(); - - return getChart().getTraceStyle(); - } - /** * Initialize UI. */ @@ -88,32 +76,31 @@ protected void initUI() */ protected void resetUI() { - // Get TraceStyle + // Get Trace Trace trace = getTrace(); if (trace == null) return; - TraceStyle traceStyle = getTraceStyle(); if (traceStyle == null) return; // Reset ShowLineCheckBox boolean showLine = trace.isShowLine(); setViewValue("ShowLineCheckBox", showLine); // Reset LineColorButton, LineColorResetButton - setViewValue("LineColorButton", traceStyle.getLineColor()); - setViewVisible("LineColorResetButton", traceStyle.isLineColorSet()); + setViewValue("LineColorButton", trace.getLineColor()); + setViewVisible("LineColorResetButton", trace.isLineColorSet()); // Reset LineWidthText, LineWidthResetButton - setViewValue("LineWidthText", traceStyle.getLineWidth()); - setViewVisible("LineWidthResetButton", traceStyle.getLineWidth() != TraceStyle.DEFAULT_LINE_WIDTH); + setViewValue("LineWidthText", trace.getLineWidth()); + setViewVisible("LineWidthResetButton", trace.getLineWidth() != TraceStyle.DEFAULT_LINE_WIDTH); // Reset LineDashButton ToggleButton lineDashButton = getView("LineDashButton", ToggleButton.class); - configureLineDashButton(lineDashButton, traceStyle.getLineDash()); + configureLineDashButton(lineDashButton, trace.getLineDash()); // Reset LineDashBox View lineDashBox = getView("LineDashBox"); ViewAnimUtils.setVisible(lineDashBox, lineDashButton.isSelected(), false, true); // Reset PointJoinComboBox - setViewSelItem("PointJoinComboBox", traceStyle.getPointJoin()); + setViewSelItem("PointJoinComboBox", trace.getPointJoin()); } /** @@ -121,9 +108,8 @@ protected void resetUI() */ protected void respondUI(ViewEvent anEvent) { - // Get TraceStyle + // Get Trace Trace trace = getTrace(); if (trace == null) return; - TraceStyle traceStyle = getTraceStyle(); if (traceStyle == null) return; // Handle ShowLineCheckBox if (anEvent.equals("ShowLineCheckBox")) { @@ -135,33 +121,33 @@ protected void respondUI(ViewEvent anEvent) // Handle LineWidthText, LineWidthAdd1Button, LineWidthSub1Button, LineWidthResetButton if (anEvent.equals("LineWidthText")) - traceStyle.setLineWidth(Math.max(anEvent.getIntValue(), 1)); + trace.setLineWidth(Math.max(anEvent.getIntValue(), 1)); if (anEvent.equals("LineWidthAdd1Button")) - traceStyle.setLineWidth(traceStyle.getLineWidth() + 1); + trace.setLineWidth(trace.getLineWidth() + 1); if (anEvent.equals("LineWidthSub1Button")) - traceStyle.setLineWidth(Math.max(traceStyle.getLineWidth() - 1, 1)); + trace.setLineWidth(Math.max(trace.getLineWidth() - 1, 1)); if (anEvent.equals("LineWidthResetButton")) - traceStyle.setLineWidth(1); + trace.setLineWidth(1); // Handle LineColorButton, LineColorResetButton if (anEvent.equals("LineColorButton")) { Color color = (Color) getViewValue("LineColorButton"); - traceStyle.setLineColor(color); + trace.setLineColor(color); } if (anEvent.equals("LineColorResetButton")) - traceStyle.setLineColor(null); + trace.setLineColor(null); // Handle LineDashButton_X String eventName = anEvent.getName(); if (eventName.startsWith("LineDashButton_")) { int id = SnapUtils.intValue(eventName); double[] dashArray = Stroke.DASHES_ALL[id]; - traceStyle.setLineDash(dashArray); + trace.setLineDash(dashArray); } // Handle PointJoinComboBox if (anEvent.equals("PointJoinComboBox")) - traceStyle.setPointJoin((PointJoin) anEvent.getSelItem()); + trace.setPointJoin((PointJoin) anEvent.getSelItem()); } /** diff --git a/src/snapcharts/apptools/TracePointStyleInsp.java b/src/snapcharts/apptools/TracePointStyleInsp.java index 930783b..ee66f3d 100644 --- a/src/snapcharts/apptools/TracePointStyleInsp.java +++ b/src/snapcharts/apptools/TracePointStyleInsp.java @@ -41,7 +41,7 @@ public TracePointStyleInsp(ChartPane aChartPane, TraceInsp aTraceInsp) @Override public ChartPart getChartPart() { - return getTraceStyle(); + return getPointStyle(); } /** @@ -54,15 +54,12 @@ public Trace getTrace() } /** - * Returns the TraceStyle. + * Returns the PointStyle. */ - public TraceStyle getTraceStyle() + public PointStyle getPointStyle() { Trace trace = getTrace(); - if (trace != null) - return trace.getTraceStyle(); - - return getChart().getTraceStyle(); + return trace != null ? trace.getPointStyle() : null; } /** @@ -88,15 +85,15 @@ protected void initUI() */ protected void resetUI() { - // Get Trace + // Get Trace, PointStyle Trace trace = getTrace(); if (trace == null) return; + PointStyle pointStyle = trace.getPointStyle(); // Reset ShowPointsCheckBox boolean showPoints = trace.isShowPoints(); setViewValue("ShowPointsCheckBox", showPoints); // Reset SymbolColorButton, SymbolColorResetButton - PointStyle pointStyle = trace.getPointStyle(); Color symbolColor = pointStyle.getFillColor(); setViewValue("SymbolColorButton", symbolColor); setViewVisible("SymbolColorResetButton", pointStyle.isFillSet()); diff --git a/src/snapcharts/apptools/TraceSpacingInsp.java b/src/snapcharts/apptools/TraceSpacingInsp.java index a751b37..bce21f7 100644 --- a/src/snapcharts/apptools/TraceSpacingInsp.java +++ b/src/snapcharts/apptools/TraceSpacingInsp.java @@ -31,7 +31,7 @@ public TraceSpacingInsp(ChartPane aChartPane) @Override public ChartPart getChartPart() { - return getTraceStyle(); + return getPointStyle(); } /** @@ -46,21 +46,10 @@ public Trace getTrace() /** * Returns the TraceStyle. */ - public TraceStyle getTraceStyle() + public PointStyle getPointStyle() { Trace trace = getTrace(); - if (trace != null) - return trace.getTraceStyle(); - - return getChart().getTraceStyle(); - } - - /** - * Initialize UI. - */ - @Override - protected void initUI() - { + return trace != null ? trace.getPointStyle() : null; } /** @@ -68,20 +57,20 @@ protected void initUI() */ protected void resetUI() { - // Get TraceStyle - TraceStyle traceStyle = getTraceStyle(); if (traceStyle == null) return; + // Get PointStyle + PointStyle pointStyle = getPointStyle(); if (pointStyle == null) return; // Reset PointSpacingText, PointSpacingResetButton - setViewValue("PointSpacingText", traceStyle.getPointSpacing()); - setViewVisible("PointSpacingResetButton", traceStyle.getPointSpacing() != TraceStyle.DEFAULT_POINT_SPACING); + setViewValue("PointSpacingText", pointStyle.getPointSpacing()); + setViewVisible("PointSpacingResetButton", pointStyle.getPointSpacing() != PointStyle.DEFAULT_POINT_SPACING); // Reset SkipPointCountText, SkipPointCountResetButton - setViewValue("SkipPointCountText", traceStyle.getSkipPointCount()); - setViewVisible("SkipPointCountResetButton", traceStyle.getSkipPointCount() != TraceStyle.DEFAULT_SKIP_POINT_COUNT); + setViewValue("SkipPointCountText", pointStyle.getSkipPointCount()); + setViewVisible("SkipPointCountResetButton", pointStyle.getSkipPointCount() != PointStyle.DEFAULT_SKIP_POINT_COUNT); // Reset MaxPointCountText, MaxPointCountResetButton - setViewValue("MaxPointCountText", traceStyle.getMaxPointCount()); - setViewVisible("MaxPointCountResetButton", traceStyle.getMaxPointCount() != TraceStyle.DEFAULT_MAX_POINT_COUNT); + setViewValue("MaxPointCountText", pointStyle.getMaxPointCount()); + setViewVisible("MaxPointCountResetButton", pointStyle.getMaxPointCount() != PointStyle.DEFAULT_MAX_POINT_COUNT); } /** @@ -89,37 +78,37 @@ protected void resetUI() */ protected void respondUI(ViewEvent anEvent) { - // Get TraceStyle - TraceStyle traceStyle = getTraceStyle(); if (traceStyle == null) return; + // Get PointStyle + PointStyle pointStyle = getPointStyle(); if (pointStyle == null) return; // Handle PointSpacingText, PointSpacingAdd1Button, PointSpacingSub1Button, PointSpacingResetButton if (anEvent.equals("PointSpacingText")) - traceStyle.setPointSpacing(Math.max(anEvent.getIntValue(), 0)); + pointStyle.setPointSpacing(Math.max(anEvent.getIntValue(), 0)); if (anEvent.equals("PointSpacingAdd1Button")) - traceStyle.setPointSpacing(traceStyle.getPointSpacing() + 1); + pointStyle.setPointSpacing(pointStyle.getPointSpacing() + 1); if (anEvent.equals("PointSpacingSub1Button")) - traceStyle.setPointSpacing(Math.max(traceStyle.getPointSpacing() - 1, 0)); + pointStyle.setPointSpacing(Math.max(pointStyle.getPointSpacing() - 1, 0)); if (anEvent.equals("PointSpacingResetButton")) - traceStyle.setPointSpacing(TraceStyle.DEFAULT_POINT_SPACING); + pointStyle.setPointSpacing(PointStyle.DEFAULT_POINT_SPACING); // Handle SkipPointCountText, SkipPointCountAdd1Button, SkipPointCountSub1Button, SkipPointCountResetButton if (anEvent.equals("SkipPointCountText")) - traceStyle.setSkipPointCount(Math.max(anEvent.getIntValue(), 0)); + pointStyle.setSkipPointCount(Math.max(anEvent.getIntValue(), 0)); if (anEvent.equals("SkipPointCountAdd1Button")) - traceStyle.setSkipPointCount(traceStyle.getSkipPointCount() + 1); + pointStyle.setSkipPointCount(pointStyle.getSkipPointCount() + 1); if (anEvent.equals("SkipPointCountSub1Button")) - traceStyle.setSkipPointCount(Math.max(traceStyle.getSkipPointCount() - 1, 0)); + pointStyle.setSkipPointCount(Math.max(pointStyle.getSkipPointCount() - 1, 0)); if (anEvent.equals("SkipPointCountResetButton")) - traceStyle.setSkipPointCount(TraceStyle.DEFAULT_SKIP_POINT_COUNT); + pointStyle.setSkipPointCount(PointStyle.DEFAULT_SKIP_POINT_COUNT); // Handle MaxPointCountText, MaxPointCountAdd1Button, MaxPointCountSub1Button, MaxPointCountResetButton if (anEvent.equals("MaxPointCountText")) - traceStyle.setMaxPointCount(Math.max(anEvent.getIntValue(), 0)); + pointStyle.setMaxPointCount(Math.max(anEvent.getIntValue(), 0)); if (anEvent.equals("MaxPointCountAdd1Button")) - traceStyle.setMaxPointCount(traceStyle.getMaxPointCount() + 1); + pointStyle.setMaxPointCount(pointStyle.getMaxPointCount() + 1); if (anEvent.equals("MaxPointCountSub1Button")) - traceStyle.setMaxPointCount(Math.max(traceStyle.getMaxPointCount() - 1, 0)); + pointStyle.setMaxPointCount(Math.max(pointStyle.getMaxPointCount() - 1, 0)); if (anEvent.equals("MaxPointCountResetButton")) - traceStyle.setMaxPointCount(TraceStyle.DEFAULT_MAX_POINT_COUNT); + pointStyle.setMaxPointCount(PointStyle.DEFAULT_MAX_POINT_COUNT); } } \ No newline at end of file diff --git a/src/snapcharts/apptools/TraceTagStyleInsp.java b/src/snapcharts/apptools/TraceTagStyleInsp.java index 5dab88b..ea29e73 100644 --- a/src/snapcharts/apptools/TraceTagStyleInsp.java +++ b/src/snapcharts/apptools/TraceTagStyleInsp.java @@ -40,7 +40,7 @@ public TraceTagStyleInsp(ChartPane aChartPane, TraceInsp aTraceInsp) @Override public ChartPart getChartPart() { - return getTraceStyle(); + return getTagStyle(); } /** @@ -55,21 +55,10 @@ public Trace getTrace() /** * Returns the TraceStyle. */ - public TraceStyle getTraceStyle() + public TagStyle getTagStyle() { Trace trace = getTrace(); - if (trace != null) - return trace.getTraceStyle(); - - return getChart().getTraceStyle(); - } - - /** - * Initialize UI. - */ - @Override - protected void initUI() - { + return trace != null ? trace.getTagStyle() : null; } /** @@ -77,15 +66,15 @@ protected void initUI() */ protected void resetUI() { - // Get Trace + // Get Trace, TagStyle Trace trace = getTrace(); if (trace == null) return; + TagStyle tagStyle = trace.getTagStyle(); // Reset ShowTagsCheckBox boolean showTags = trace.isShowTags(); setViewValue("ShowTagsCheckBox", showTags); // Reset TagFontText, TagFontResetButton - TagStyle tagStyle = trace.getTagStyle(); Font tagFont = tagStyle.getFont(); String fontName = tagFont.getName() + ' ' + FormatUtils.formatNum(tagFont.getSize()); setViewValue("TagFontText", fontName); diff --git a/src/snapcharts/model/Chart.java b/src/snapcharts/model/Chart.java index 03ce3a2..3f9b1c6 100644 --- a/src/snapcharts/model/Chart.java +++ b/src/snapcharts/model/Chart.java @@ -57,9 +57,6 @@ public class Chart extends ParentPart { // The trace colors private Color[] _colors = ColorMap.GT_COLORS; - // The object holding specific chart type properties - private TraceStyleHpr _traceStyleHpr = new TraceStyleHpr(this); - // Constants for properties public static final String Type_Prop = "Type"; public static final String Colors_Prop = "Colors"; @@ -320,16 +317,6 @@ public Color getColor(int anIndex) return ColorMap.COLORS[index]; } - /** - * Returns the TraceStyleHpr that provides/manages TraceStyles. - */ - public TraceStyleHpr getTraceStyleHelper() { return _traceStyleHpr; } - - /** - * Returns the TraceStyle for this chart (ChartType). - */ - public TraceStyle getTraceStyle() { return _traceStyleHpr.getTraceStyle(); } - /** * Called when chart part has prop change. */ diff --git a/src/snapcharts/model/ChartPart.java b/src/snapcharts/model/ChartPart.java index c5c189b..6955ab5 100644 --- a/src/snapcharts/model/ChartPart.java +++ b/src/snapcharts/model/ChartPart.java @@ -178,15 +178,6 @@ protected void setParent(ChartPart aParent) _parent = aParent; } - /** - * Returns the TraceStyle. - */ - public TraceStyle getTraceStyle() - { - Chart chart = getChart(); - return chart != null ? chart.getTraceStyle() : null; - } - /** * Returns the TraceList. */ diff --git a/src/snapcharts/model/PointStyle.java b/src/snapcharts/model/PointStyle.java index f0b6f05..ad78054 100644 --- a/src/snapcharts/model/PointStyle.java +++ b/src/snapcharts/model/PointStyle.java @@ -25,15 +25,30 @@ public class PointStyle extends ChartPart { // The cached symbol private Symbol _symbol; + // The maximum number of symbols/tags visible + private int _maxPointCount = DEFAULT_MAX_POINT_COUNT; + + // The number of symbols/tags to skip to avoid excessive overlap + private int _skipPointCount = DEFAULT_SKIP_POINT_COUNT; + + // The minimum amount of space between symbols/tags to avoid excessive overlap + private int _pointSpacing = DEFAULT_POINT_SPACING; + // Constants for properties public static final String SymbolSize_Prop = "SymbolSize"; public static final String SymbolId_Prop = "SymbolId"; + public static final String PointSpacing_Prop = "PointSpacing"; + public static final String MaxPointCount_Prop = "MaxPointCount"; + public static final String SkipPointCount_Prop = "SkipPointCount"; // Constants for property defaults public static final int DEFAULT_SYMBOL_SIZE = 8; public static final Color DEFAULT_SYMBOL_FILL = null; public static final Color DEFAULT_SYMBOL_BORDER_COLOR = null; //Color.BLACK; public static final int DEFAULT_SYMBOL_BORDER_WIDTH = 0; + public static final int DEFAULT_POINT_SPACING = 0; + public static final int DEFAULT_MAX_POINT_COUNT = 0; + public static final int DEFAULT_SKIP_POINT_COUNT = 0; /** * Constructor. @@ -87,12 +102,54 @@ public Symbol getSymbol() return _symbol = symbol; } + /** + * Returns the minimum amount of space between symbols/tags to avoid excessive overlap. + */ + public int getPointSpacing() { return _pointSpacing; } + + /** + * Sets the minimum amount of space between symbols/tags to avoid excessive overlap. + */ + public void setPointSpacing(int aValue) + { + if (aValue == getPointSpacing()) return; + firePropChange(PointSpacing_Prop, _pointSpacing, _pointSpacing = aValue); + } + + /** + * Returns the maximum number of symbols/tags visible. + */ + public int getMaxPointCount() { return _maxPointCount; } + + /** + * Sets the maximum number of symbols/tags visible. + */ + public void setMaxPointCount(int aValue) + { + if (aValue == getMaxPointCount()) return; + firePropChange(MaxPointCount_Prop, _maxPointCount, _maxPointCount = aValue); + } + + /** + * Returns the number of symbols/tags to skip to avoid excessive overlap. + */ + public int getSkipPointCount() { return _skipPointCount; } + + /** + * Sets the number of symbols/tags to skip to avoid excessive overlap. + */ + public void setSkipPointCount(int aValue) + { + if (aValue == getSkipPointCount()) return; + firePropChange(SkipPointCount_Prop, _skipPointCount, _skipPointCount = aValue); + } + /** * Returns the default fill color. */ private Color getDefaultLineColor() { - return _trace.getTraceStyle().getLineColor(); + return _trace.getLineColor(); } /** @@ -102,7 +159,7 @@ private Color getDefaultFillColor() { if (getLineWidth() > 0 && !isLineColorSet()) return Color.WHITE; - return _trace.getTraceStyle().getDefaultLineColor(); + return _trace.getDefaultLineColor(); } /** @@ -121,7 +178,7 @@ protected void initPropDefaults(PropDefaults aPropDefaults) super.initPropDefaults(aPropDefaults); // Add Props - aPropDefaults.addProps(SymbolSize_Prop, SymbolId_Prop); + aPropDefaults.addProps(SymbolSize_Prop, SymbolId_Prop, PointSpacing_Prop, MaxPointCount_Prop, SkipPointCount_Prop); } /** @@ -137,6 +194,11 @@ public Object getPropValue(String aPropName) case SymbolSize_Prop: return getSymbolSize(); case SymbolId_Prop: return getSymbolId(); + // Handle PointSpacing, MaxPointCount, SkipPointCount + case PointSpacing_Prop: return getPointSpacing(); + case MaxPointCount_Prop: return getMaxPointCount(); + case SkipPointCount_Prop: return getSkipPointCount(); + // Handle super class properties (or unknown) default: return super.getPropValue(aPropName); } @@ -155,6 +217,11 @@ public void setPropValue(String aPropName, Object aValue) case SymbolSize_Prop: setSymbolSize(SnapUtils.intValue(aValue)); break; case SymbolId_Prop: setSymbolId(SnapUtils.intValue(aValue)); break; + // Handle PointSpacing, MaxPointCount, SkipPointCount + case PointSpacing_Prop: setPointSpacing(SnapUtils.intValue(aValue)); break; + case MaxPointCount_Prop: setMaxPointCount(SnapUtils.intValue(aValue)); break; + case SkipPointCount_Prop: setSkipPointCount(SnapUtils.intValue(aValue)); break; + // Handle super class properties (or unknown) default: super.setPropValue(aPropName, aValue); break; } @@ -168,15 +235,18 @@ public Object getPropDefault(String aPropName) { switch (aPropName) { - // LineColor_Prop + // Override LineColor, Fill case LineColor_Prop: return getDefaultLineColor(); + case Fill_Prop: return getDefaultFillColor(); // SymbolSize, SymbolId case SymbolSize_Prop: return DEFAULT_SYMBOL_SIZE; case SymbolId_Prop: return 0; - // Fill_Prop - case Fill_Prop: return getDefaultFillColor(); + // PointSpacing properties + case PointSpacing_Prop: return DEFAULT_POINT_SPACING; + case MaxPointCount_Prop: return DEFAULT_MAX_POINT_COUNT; + case SkipPointCount_Prop: return DEFAULT_SKIP_POINT_COUNT; // Do normal version default: return super.getPropDefault(aPropName); @@ -192,14 +262,20 @@ public XMLElement toXML(XMLArchiver anArchiver) // Archive basic attributes XMLElement e = super.toXML(anArchiver); - // Archive SymbolSize + // Archive SymbolSize, SymbolId if (!isPropDefault(SymbolSize_Prop)) e.add(SymbolSize_Prop, getSymbolSize()); - - // Archive SymbolId if (!isPropDefault(SymbolSize_Prop)) e.add(SymbolId_Prop, getSymbolId()); + // Archive PointSpacing, MaxPointCount, SkipPointCount + if (!isPropDefault(PointSpacing_Prop)) + e.add(PointSpacing_Prop, getPointSpacing()); + if (!isPropDefault(MaxPointCount_Prop)) + e.add(MaxPointCount_Prop, getMaxPointCount()); + if (!isPropDefault(SkipPointCount_Prop)) + e.add(SkipPointCount_Prop, getSkipPointCount()); + // Return xml return e; } @@ -213,15 +289,20 @@ public Object fromXML(XMLArchiver anArchiver, XMLElement anElement) // Unarchive basic attributes super.fromXML(anArchiver, anElement); - - // Unarchive SymbolSize + // Unarchive SymbolSize, SymbolId if (anElement.hasAttribute(SymbolSize_Prop)) setSymbolSize(anElement.getAttributeIntValue(SymbolSize_Prop)); - - // Unarchive SymbolId if (anElement.hasAttribute(SymbolId_Prop)) setSymbolId(anElement.getAttributeIntValue(SymbolId_Prop, 0)); + // Unarchive PointSpacing, MaxPointCount, SkipPointCount + if (anElement.hasAttribute(PointSpacing_Prop)) + setPointSpacing(anElement.getAttributeIntValue(PointSpacing_Prop)); + if (anElement.hasAttribute(MaxPointCount_Prop)) + setMaxPointCount(anElement.getAttributeIntValue(MaxPointCount_Prop)); + if (anElement.hasAttribute(SkipPointCount_Prop)) + setSkipPointCount(anElement.getAttributeIntValue(SkipPointCount_Prop)); + // Return return this; } diff --git a/src/snapcharts/model/TagStyle.java b/src/snapcharts/model/TagStyle.java index bbe1fb3..c9a0d69 100644 --- a/src/snapcharts/model/TagStyle.java +++ b/src/snapcharts/model/TagStyle.java @@ -55,7 +55,7 @@ public Object getPropDefault(String aPropName) switch (aPropName) { // Handle LineColor - case LineColor_Prop: return _trace.getTraceStyle().getLineColor(); + case LineColor_Prop: return _trace.getLineColor(); // Handle LineColor case Fill_Prop: return getDefaultFill(); @@ -76,7 +76,6 @@ public XMLElement toXML(XMLArchiver anArchiver) { // Archive basic attributes XMLElement e = super.toXML(anArchiver); - e.setName("TagStyle"); // Return xml return e; diff --git a/src/snapcharts/model/Trace.java b/src/snapcharts/model/Trace.java index fe66c11..8ab4d6c 100644 --- a/src/snapcharts/model/Trace.java +++ b/src/snapcharts/model/Trace.java @@ -2,6 +2,7 @@ * Copyright (c) 2010, ReportMill Software. All rights reserved. */ package snapcharts.model; +import snap.gfx.Color; import snap.util.*; import snapcharts.data.*; import snapcharts.util.MinMax; @@ -29,6 +30,21 @@ public class Trace extends ChartPart { // Whether to show data tags private boolean _showTags; + // The method by which points are joined + private PointJoin _pointJoin; + + // The FillMode + private FillMode _fillMode; + + // The PointStyle + private PointStyle _pointStyle = new PointStyle(this); + + // The TagStyle + private TagStyle _tagStyle = new TagStyle(this); + + // The TraceStyleHpr + private TraceStyleHpr _traceStyleHpr; + // The Y Axis type private AxisType _axisTypeY = AxisType.Y; @@ -50,15 +66,6 @@ public class Trace extends ChartPart { // Whether to show legend entry private boolean _showLegendEntry = true; - // The TraceStyleHpr - private TraceStyleHpr _traceStyleHpr; - - // The PointStyle - private PointStyle _pointStyle = new PointStyle(this); - - // The TagStyle - private TagStyle _tagStyle = new TagStyle(this); - // The original DataSet private DataSet _dataSet = DataSet.newDataSet(); @@ -74,11 +81,16 @@ public class Trace extends ChartPart { // Processed data in polar XY form private DataSet _polarXYData; + // Constant for how Trace area should be filled + public enum FillMode { None, ToZeroY, ToNextY, ToZeroX, ToNextX, ToSelf, ToNext } + // Constants for properties public static final String ShowLine_Prop = "ShowLine"; public static final String ShowArea_Prop = "ShowArea"; public static final String ShowPoints_Prop = "ShowPoints"; public static final String ShowTags_Prop = "ShowTags"; + public static final String PointJoin_Prop = "PointJoin"; + public static final String FillMode_Prop = "FillMode"; public static final String DataType_Prop = DataSet.DataType_Prop; public static final String ThetaUhit_Prop = "ThetaUnit"; public static final String AxisTypeY_Prop = "AxisTypeY"; @@ -93,6 +105,12 @@ public class Trace extends ChartPart { // Constants for relations public static final String PointStyle_Rel = "PointStyle"; public static final String TagStyle_Rel = "TagStyle"; + public static final String TraceStyle_Rel = "TraceStyle"; + + // Properties for defaults + public static final int DEFAULT_LINE_WIDTH = 1; + public static final PointJoin DEFAULT_POINT_JOIN = PointJoin.Line; + public static final FillMode DEFAULT_FILL_MODE = FillMode.None; /** * Constructor. @@ -101,11 +119,17 @@ public Trace() { super(); - _traceStyleHpr = new TraceStyleHpr(this); + // Set defaults + _lineWidth = DEFAULT_LINE_WIDTH; + _pointJoin = DEFAULT_POINT_JOIN; + _fillMode = DEFAULT_FILL_MODE; // Register listener for TagStyle, PointStyle prop changes _tagStyle.addPropChangeListener(pc -> childChartPartDidPropChange(pc)); _pointStyle.addPropChangeListener(pc -> childChartPartDidPropChange(pc)); + + // Configure TraceStyle via TraceStyleHpr + _traceStyleHpr = new TraceStyleHpr(this); } /** @@ -181,6 +205,34 @@ public void setShowTags(boolean aValue) firePropChange(ShowTags_Prop, _showTags, _showTags = aValue); } + /** + * Returns the method by which points are joined. + */ + public PointJoin getPointJoin() { return _pointJoin; } + + /** + * Sets the method by which points are joined. + */ + public void setPointJoin(PointJoin aPointJoin) + { + if (aPointJoin == getPointJoin()) return; + firePropChange(PointJoin_Prop, _pointJoin, _pointJoin = aPointJoin); + } + + /** + * Returns the FillMode (how/whether to paint the data area). + */ + public FillMode getFillMode() { return _fillMode; } + + /** + * Sets the FillMode (how/whether to paint the data area). + */ + public void setFillMode(FillMode aFillMode) + { + if (aFillMode == _fillMode) return; + firePropChange(FillMode_Prop, _fillMode, _fillMode = aFillMode); + } + /** * Returns the PointStyle for this Trace. */ @@ -191,6 +243,58 @@ public void setShowTags(boolean aValue) */ public TagStyle getTagStyle() { return _tagStyle; } + /** + * Returns the TraceStyle for this trace (and ChartType). + */ + public TraceStyle getTraceStyle() + { + ChartType chartType = getTraceChartType(); + return _traceStyleHpr.getTraceStyleForChartType(chartType); + } + + /** + * Returns the Trace ChartType. This should be the same as Chart.ChartType, but can be overridden. + */ + public ChartType getTraceChartType() + { + // Get Chart.ChartType + ChartType chartType = getChartType(); + + // If Contour but no Z data, use Scatter instead + if (chartType.isContourType() && !getDataType().hasZ()) + chartType = chartType.isPolarType() ? ChartType.POLAR : ChartType.SCATTER; + + // Return ChartType + return chartType; + } + + /** + * Returns the default line color. + */ + public Color getDefaultLineColor() + { + int index = getIndex(); + return getColorMapColor(index); + } + + /** + * Returns the color map color at index. + */ + public Color getColorMapColor(int anIndex) + { + Chart chart = getChart(); + return chart.getColor(anIndex); + } + + /** + * Returns the default color to fill the data area. + */ + public Color getFillColorDefault() + { + // Get from LineColor, half transparent + return getDefaultLineColor().copyForAlpha(.5); + } + /** * Returns the DataType. */ @@ -351,31 +455,6 @@ public void setShowLegendEntry(boolean aValue) firePropChange(ShowLegendEntry_Prop, _showLegendEntry, _showLegendEntry = aValue); } - /** - * Returns the TraceStyle for this trace (and ChartType). - */ - public TraceStyle getTraceStyle() - { - ChartType chartType = getTraceChartType(); - return _traceStyleHpr.getTraceStyleForChartType(chartType); - } - - /** - * Returns the Trace ChartType. This should be the same as Chart.ChartType, but can be overridden. - */ - public ChartType getTraceChartType() - { - // Get Chart.ChartType - ChartType chartType = getChartType(); - - // If Contour but no Z data, use Scatter instead - if (chartType.isContourType() && !getDataType().hasZ()) - chartType = chartType.isPolarType() ? ChartType.POLAR : ChartType.SCATTER; - - // Return ChartType - return chartType; - } - /** * Returns the number of rows. */ @@ -781,6 +860,12 @@ protected void clearCachedData() _polarXYData = null; } + /** + * Override to prevent client code from using border instead of line props. + */ + @Override + public boolean isBorderSupported() { return false; } + /** * Standard toString implementation. */ @@ -815,9 +900,11 @@ protected void initPropDefaults(PropDefaults aPropDefaults) super.initPropDefaults(aPropDefaults); // Add Props - aPropDefaults.addProps(ShowLine_Prop, ShowArea_Prop, ShowPoints_Prop, ShowTags_Prop); + aPropDefaults.addProps(ShowLine_Prop, ShowArea_Prop, ShowPoints_Prop, ShowTags_Prop, + PointJoin_Prop, FillMode_Prop); - aPropDefaults.addRelations(PointStyle_Rel, TagStyle_Rel); + // Add Relations + aPropDefaults.addRelations(PointStyle_Rel, TagStyle_Rel, TraceStyle_Rel); } /** @@ -835,9 +922,14 @@ public Object getPropValue(String aPropName) case ShowPoints_Prop: return isShowPoints(); case ShowTags_Prop: return isShowTags(); - // Handle PointStyleRel, TagStyle_Rel + // Handle PointJoin, FillMode + case PointJoin_Prop: return getPointJoin(); + case FillMode_Prop: return getFillMode(); + + // Handle PointStyleRel, TagStyle_Rel, TraceStyle_Rel case PointStyle_Rel: return getPointStyle(); case TagStyle_Rel: return getTagStyle(); + case TraceStyle_Rel: return getTraceStyle(); // Handle super class properties (or unknown) default: return super.getPropValue(aPropName); @@ -859,11 +951,39 @@ public void setPropValue(String aPropName, Object aValue) case ShowPoints_Prop: setShowPoints(SnapUtils.boolValue(aValue)); break; case ShowTags_Prop: setShowTags(SnapUtils.boolValue(aValue)); break; + // Handle PointJoint, FillMode + case PointJoin_Prop: setPointJoin((PointJoin) aValue); break; + case FillMode_Prop: setFillMode((FillMode) aValue); break; + // Handle super class properties (or unknown) default: super.setPropValue(aPropName, aValue); } } + /** + * Override to define TraceStyle defaults + */ + @Override + public Object getPropDefault(String aPropName) + { + switch (aPropName) { + + // Override LineColor_Prop, LineWidth_Prop + case LineColor_Prop: return getDefaultLineColor(); + case LineWidth_Prop: return DEFAULT_LINE_WIDTH; + + // Override Fill + case Fill_Prop: return getFillColorDefault(); + + // PointJoin, FillMode + case PointJoin_Prop: return DEFAULT_POINT_JOIN; + case FillMode_Prop: return DEFAULT_FILL_MODE; + + // Do normal version + default: return super.getPropDefault(aPropName); + } + } + /** * Archival. */ @@ -873,33 +993,21 @@ public XMLElement toXML(XMLArchiver anArchiver) // Archive basic attributes XMLElement e = super.toXML(anArchiver); - // Archive ShowLine, ShowArea + // Archive ShowLine, ShowArea, ShowPoints, ShowTags if (!isShowLine()) e.add(ShowLine_Prop, false); if (isShowArea()) e.add(ShowArea_Prop, true); - - // Archive ShowPoints - if (isShowPoints()) { + if (isShowPoints()) e.add(ShowPoints_Prop, true); - - // Archive PointStyle - PointStyle pointStyle = getPointStyle(); - XMLElement pointStyleXML = pointStyle.toXML(anArchiver); - if (pointStyleXML.getAttributeCount() > 0 || pointStyleXML.getElementCount() > 0) - e.addElement(pointStyleXML); - } - - // Archive ShowTags - if (isShowTags()) { + if (isShowTags()) e.add(ShowTags_Prop, true); - // Archive TagStyle - TagStyle tagStyle = getTagStyle(); - XMLElement tagStyleXML = tagStyle.toXML(anArchiver); - if (tagStyleXML.getAttributeCount() > 0 || tagStyleXML.getElementCount() > 0) - e.addElement(tagStyleXML); - } + // Archive PointJoin, FillMode + if (!isPropDefault(PointJoin_Prop)) + e.add(PointJoin_Prop, getPointJoin()); + if (!isPropDefault(FillMode_Prop)) + e.add(FillMode_Prop, getFillMode()); // Archive AxisTypeY if (getAxisTypeY() != AxisType.Y) @@ -921,13 +1029,23 @@ public XMLElement toXML(XMLArchiver anArchiver) if (!isShowLegendEntry()) e.add(ShowLegendEntry_Prop, false); + // Archive PointStyle + PointStyle pointStyle = getPointStyle(); + XMLElement pointStyleXML = pointStyle.toXML(anArchiver); + if (pointStyleXML.getAttributeCount() > 0 || pointStyleXML.getElementCount() > 0) + e.addElement(pointStyleXML); + + // Archive TagStyle + TagStyle tagStyle = getTagStyle(); + XMLElement tagStyleXML = tagStyle.toXML(anArchiver); + if (tagStyleXML.getAttributeCount() > 0 || tagStyleXML.getElementCount() > 0) + e.addElement(tagStyleXML); + // Archive TraceStyle TraceStyle traceStyle = getTraceStyle(); XMLElement traceStyleXML = traceStyle.toXML(anArchiver); - if (traceStyleXML.getAttributeCount() > 0) { - traceStyleXML.setName("TraceStyle"); + if (traceStyleXML.getAttributeCount() > 0 || traceStyleXML.getElementCount() > 0) e.addElement(traceStyleXML); - } // Archive DataSet DataSet dataSet = getDataSet(); @@ -946,31 +1064,34 @@ public Object fromXML(XMLArchiver anArchiver, XMLElement anElement) // Unarchive basic attributes super.fromXML(anArchiver, anElement); - // Unarchive ShowLine, ShowArea + // This is for brief time when DataStyle (TraceStyle) held standard Trace display props + XMLElement dataStyleXML = anElement.getElement("DataStyle"); + if (dataStyleXML != null) + fromLegacyDataStyleXML(anArchiver, dataStyleXML); + + // Unarchive ShowLine, ShowArea, ShowPoints, ShowTags if (anElement.hasAttribute(ShowLine_Prop)) setShowLine(anElement.getAttributeBoolValue(ShowLine_Prop)); if (anElement.hasAttribute(ShowArea_Prop)) setShowArea(anElement.getAttributeBoolValue(ShowArea_Prop)); - - // Unarchive ShowPoints (and legacy ShowSymbols) if (anElement.hasAttribute(ShowPoints_Prop)) setShowPoints(anElement.getAttributeBoolValue(ShowPoints_Prop)); - else if (anElement.hasAttribute("ShowSymbols")) - setShowPoints(anElement.getAttributeBoolValue("ShowSymbols")); - - // Unarchive ShowTags if (anElement.hasAttribute(ShowTags_Prop)) setShowTags(anElement.getAttributeBoolValue(ShowTags_Prop)); + // Unarchive PointJoin, FillMode + if (anElement.hasAttribute(PointJoin_Prop)) + setPointJoin(anElement.getAttributeEnumValue(PointJoin_Prop, PointJoin.class, DEFAULT_POINT_JOIN)); + if (anElement.hasAttribute(FillMode_Prop)) + setFillMode(anElement.getAttributeEnumValue(FillMode_Prop, FillMode.class, DEFAULT_FILL_MODE)); + // Unarchive PointStyle - XMLElement pointStyleXML = anElement.getElement("PointStyle"); - if (pointStyleXML == null) - pointStyleXML = anElement.getElement("SymbolStyle"); + XMLElement pointStyleXML = anElement.getElement(PointStyle_Rel); if (pointStyleXML != null) getPointStyle().fromXML(anArchiver, pointStyleXML); // Unarchive TagStyle - XMLElement tagStyleXML = anElement.getElement("TagStyle"); + XMLElement tagStyleXML = anElement.getElement(TagStyle_Rel); if (tagStyleXML != null) getTagStyle().fromXML(anArchiver, tagStyleXML); @@ -996,12 +1117,9 @@ else if (anElement.hasAttribute("ShowSymbols")) setShowLegendEntry(anElement.getAttributeBoolValue(ShowLegendEntry_Prop)); // Unarchive TraceStyle - XMLElement traceStyleXML = anElement.getElement("TraceStyle"); - if (traceStyleXML == null) - traceStyleXML = anElement.getElement("DataStyle"); - if (traceStyleXML != null) { + XMLElement traceStyleXML = anElement.getElement(TraceStyle_Rel); + if (traceStyleXML != null) getTraceStyle().fromXML(anArchiver, traceStyleXML); - } // Unarchive DataSet DataSet dataSet = getDataSet(); @@ -1010,4 +1128,36 @@ else if (anElement.hasAttribute("ShowSymbols")) // Return this part return this; } + + /** + * Legacy unarchival for time when DataStyle held most Trace display properties. + */ + private void fromLegacyDataStyleXML(XMLArchiver anArchiver, XMLElement anElement) + { + if (anElement.hasAttribute(Trace.ShowLine_Prop) || anElement.hasAttribute(FillMode_Prop)) + super.fromXML(anArchiver, anElement); + + if (anElement.hasAttribute(Trace.ShowLine_Prop)) + setShowLine(anElement.getAttributeBoolValue(Trace.ShowLine_Prop)); + if (anElement.hasAttribute(FillMode_Prop)) + setShowArea(true); + if (anElement.hasAttribute("ShowSymbols")) + setShowPoints(anElement.getAttributeBoolValue("ShowSymbols")); + if (anElement.hasAttribute(Trace.ShowTags_Prop)) + setShowTags(anElement.getAttributeBoolValue(Trace.ShowTags_Prop)); + XMLElement pointStyleXML = anElement.getElement("SymbolStyle"); + if (pointStyleXML != null) + getPointStyle().fromXML(anArchiver, pointStyleXML); + XMLElement tagStyleXML = anElement.getElement("TagStyle"); + if (tagStyleXML != null) + getTagStyle().fromXML(anArchiver, tagStyleXML); + if (anElement.hasAttribute(PointJoin_Prop)) + setPointJoin(anElement.getAttributeEnumValue(PointJoin_Prop, PointJoin.class, null)); + if (anElement.hasAttribute(PointStyle.PointSpacing_Prop)) + getPointStyle().setPointSpacing(anElement.getAttributeIntValue(PointStyle.PointSpacing_Prop)); + if (anElement.hasAttribute(PointStyle.MaxPointCount_Prop)) + getPointStyle().setMaxPointCount(anElement.getAttributeIntValue(PointStyle.MaxPointCount_Prop)); + if (anElement.hasAttribute(PointStyle.SkipPointCount_Prop)) + getPointStyle().setSkipPointCount(anElement.getAttributeIntValue(PointStyle.SkipPointCount_Prop)); + } } \ No newline at end of file diff --git a/src/snapcharts/model/TraceStyle.java b/src/snapcharts/model/TraceStyle.java index ef3f5d7..7775d0b 100644 --- a/src/snapcharts/model/TraceStyle.java +++ b/src/snapcharts/model/TraceStyle.java @@ -2,173 +2,18 @@ * Copyright (c) 2010, ReportMill Software. All rights reserved. */ package snapcharts.model; -import snap.gfx.Color; -import snap.util.*; /** * A class to represent properties to render data for a specific ChartType. */ public class TraceStyle extends ChartPart { - // The method by which points are joined - private PointJoin _pointJoin = PointJoin.Line; - - // The FillMode - private FillMode _fillMode = FillMode.None; - - // The maximum number of symbols/tags visible - private int _maxPointCount = DEFAULT_MAX_POINT_COUNT; - - // The number of symbols/tags to skip to avoid excessive overlap - private int _skipPointCount = DEFAULT_SKIP_POINT_COUNT; - - // The minimum amount of space between symbols/tags to avoid excessive overlap - private int _pointSpacing = DEFAULT_POINT_SPACING; - - // Constants for properties - public static final String PointJoin_Prop = "PointJoin"; - public static final String FillMode_Prop = "FillMode"; - public static final String PointSpacing_Prop = "PointSpacing"; - public static final String MaxPointCount_Prop = "MaxPointCount"; - public static final String SkipPointCount_Prop = "SkipPointCount"; - - // Constants for property defaults - public static final int DEFAULT_LINE_WIDTH = 1; - public static final PointJoin DEFAULT_POINT_JOIN = PointJoin.Line; - public static final FillMode DEFAULT_FILL_MODE = FillMode.None; - public static final int DEFAULT_POINT_SPACING = 0; - public static final int DEFAULT_MAX_POINT_COUNT = 0; - public static final int DEFAULT_SKIP_POINT_COUNT = 0; - - // Constant for how Trace area should be filled - public enum FillMode { None, ToZeroY, ToNextY, ToZeroX, ToNextX, ToSelf, ToNext }; - /** * Constructor. */ public TraceStyle() { super(); - setLineWidth(DEFAULT_LINE_WIDTH); - } - - /** - * Returns the default line color. - */ - public Color getDefaultLineColor() - { - // Get from Trace - ChartPart parent = getParent(); - if (parent instanceof Trace) { - Trace trace = (Trace) parent; - int index = trace.getIndex(); - return getColorMapColor(index); - } - - // Shouldn't get here - return Color.BLACK; - } - - /** - * Returns the color map color at index. - */ - public Color getColorMapColor(int anIndex) - { - Chart chart = getChart(); - return chart.getColor(anIndex); - } - - /** - * Returns the method by which points are joined. - */ - public PointJoin getPointJoin() { return _pointJoin; } - - /** - * Sets the method by which points are joined. - */ - public void setPointJoin(PointJoin aPointJoin) - { - if (aPointJoin == getPointJoin()) return; - firePropChange(PointJoin_Prop, _pointJoin, _pointJoin = aPointJoin); - } - - /** - * Returns whether to paint area for data. - */ - //public boolean isShowArea() { return _fillMode != FillMode.None; } - - /** - * Sets whether to paint area for data. - */ - /*public void setShowArea(boolean aValue) - { - FillMode fillMode = aValue ? FillMode.ToZeroY : FillMode.None; - setFillMode(fillMode); - }*/ - - /** - * Returns the default color to fill the data area. - */ - public Color getFillColorDefault() - { - // Get from LineColor, half transparent - return getDefaultLineColor().copyForAlpha(.5); - } - - /** - * Returns the FillMode (how/whether to paint the data area). - */ - public FillMode getFillMode() { return _fillMode; } - - /** - * Sets the FillMode (how/whether to paint the data area). - */ - public void setFillMode(FillMode aFillMode) - { - if (aFillMode == _fillMode) return; - firePropChange(FillMode_Prop, _fillMode, _fillMode = aFillMode); - } - - /** - * Returns the minimum amount of space between symbols/tags to avoid excessive overlap. - */ - public int getPointSpacing() { return _pointSpacing; } - - /** - * Sets the minimum amount of space between symbols/tags to avoid excessive overlap. - */ - public void setPointSpacing(int aValue) - { - if (aValue == getPointSpacing()) return; - firePropChange(PointSpacing_Prop, _pointSpacing, _pointSpacing = aValue); - } - - /** - * Returns the maximum number of symbols/tags visible. - */ - public int getMaxPointCount() { return _maxPointCount; } - - /** - * Sets the maximum number of symbols/tags visible. - */ - public void setMaxPointCount(int aValue) - { - if (aValue == getMaxPointCount()) return; - firePropChange(MaxPointCount_Prop, _maxPointCount, _maxPointCount = aValue); - } - - /** - * Returns the number of symbols/tags to skip to avoid excessive overlap. - */ - public int getSkipPointCount() { return _skipPointCount; } - - /** - * Sets the number of symbols/tags to skip to avoid excessive overlap. - */ - public void setSkipPointCount(int aValue) - { - if (aValue == getSkipPointCount()) return; - firePropChange(SkipPointCount_Prop, _skipPointCount, _skipPointCount = aValue); } /** @@ -176,174 +21,4 @@ public void setSkipPointCount(int aValue) */ @Override public boolean isBorderSupported() { return false; } - - /** - * Override to register props. - */ - @Override - protected void initPropDefaults(PropDefaults aPropDefaults) - { - // Do normal version - super.initPropDefaults(aPropDefaults); - - // Add Props - aPropDefaults.addProps(PointJoin_Prop, FillMode_Prop, - PointSpacing_Prop, MaxPointCount_Prop, SkipPointCount_Prop); - } - - /** - * Returns the prop value for given key. - */ - @Override - public Object getPropValue(String aPropName) - { - // Handle properties - switch (aPropName) { - - // Handle PointJoin - case PointJoin_Prop: return getPointJoin(); - - // Handle FillMode - case FillMode_Prop: return getFillMode(); - - // Handle PointSpacing, MaxPointCount, SkipPointCount - case PointSpacing_Prop: return getPointSpacing(); - case MaxPointCount_Prop: return getMaxPointCount(); - case SkipPointCount_Prop: return getSkipPointCount(); - - // Handle super class properties (or unknown) - default: return super.getPropValue(aPropName); - } - } - - /** - * Sets the prop value for given key. - */ - @Override - public void setPropValue(String aPropName, Object aValue) - { - // Handle properties - switch (aPropName) { - - // Handle PointJoint - case PointJoin_Prop: setPointJoin((PointJoin) aValue); break; - - // Handle FillMode - case FillMode_Prop: setFillMode((FillMode) aValue); break; - - // Handle PointSpacing, MaxPointCount, SkipPointCount - case PointSpacing_Prop: setPointSpacing(SnapUtils.intValue(aValue)); break; - case MaxPointCount_Prop: setMaxPointCount(SnapUtils.intValue(aValue)); break; - case SkipPointCount_Prop: setSkipPointCount(SnapUtils.intValue(aValue)); break; - - // Handle super class properties (or unknown) - default: super.setPropValue(aPropName, aValue); - } - } - - /** - * Override to define TraceStyle defaults - */ - @Override - public Object getPropDefault(String aPropName) - { - switch (aPropName) { - - // Override LineColor_Prop, LineWidth_Prop - case LineColor_Prop: return getDefaultLineColor(); - case LineWidth_Prop: return DEFAULT_LINE_WIDTH; - - // Override Fill - case Fill_Prop: return getFillColorDefault(); - - // PointJoin, FillMode - case PointJoin_Prop: return DEFAULT_POINT_JOIN; - case FillMode_Prop: return DEFAULT_FILL_MODE; - - // PointSpacing properties - case PointSpacing_Prop: return DEFAULT_POINT_SPACING; - case MaxPointCount_Prop: return DEFAULT_MAX_POINT_COUNT; - case SkipPointCount_Prop: return DEFAULT_SKIP_POINT_COUNT; - default: return super.getPropDefault(aPropName); - } - } - - /** - * Archival. - */ - @Override - public XMLElement toXML(XMLArchiver anArchiver) - { - // Archive basic attributes - XMLElement e = super.toXML(anArchiver); - - // Archive PointJoin - if (!isPropDefault(PointJoin_Prop)) - e.add(PointJoin_Prop, getPointJoin()); - - // Archive FillMode - if (!isPropDefault(FillMode_Prop)) - e.add(FillMode_Prop, getFillMode()); - - // Archive PointSpacing, MaxPointCount, SkipPointCount - if (!isPropDefault(PointSpacing_Prop)) - e.add(PointSpacing_Prop, getPointSpacing()); - if (!isPropDefault(MaxPointCount_Prop)) - e.add(MaxPointCount_Prop, getMaxPointCount()); - if (!isPropDefault(SkipPointCount_Prop)) - e.add(SkipPointCount_Prop, getSkipPointCount()); - - // Return element - return e; - } - - /** - * Unarchival. - */ - @Override - public Object fromXML(XMLArchiver anArchiver, XMLElement anElement) - { - // Unarchive basic attributes - super.fromXML(anArchiver, anElement); - - // Unarchive FillMode - if (anElement.hasAttribute(PointJoin_Prop)) - setPointJoin(anElement.getAttributeEnumValue(PointJoin_Prop, PointJoin.class, DEFAULT_POINT_JOIN)); - - // Unarchive FillMode - if (anElement.hasAttribute(FillMode_Prop)) - setFillMode(anElement.getAttributeEnumValue(FillMode_Prop, FillMode.class, DEFAULT_FILL_MODE)); - - // Unarchive PointSpacing, MaxPointCount, SkipPointCount - if (anElement.hasAttribute(PointSpacing_Prop)) - setPointSpacing(anElement.getAttributeIntValue(PointSpacing_Prop)); - if (anElement.hasAttribute(MaxPointCount_Prop)) - setMaxPointCount(anElement.getAttributeIntValue(MaxPointCount_Prop)); - if (anElement.hasAttribute(SkipPointCount_Prop)) - setSkipPointCount(anElement.getAttributeIntValue(SkipPointCount_Prop)); - - // Legacy stuff - Trace trace = (Trace) getParent(); - if (anElement.hasAttribute(Trace.ShowLine_Prop)) - trace.setShowLine(anElement.getAttributeBoolValue(Trace.ShowLine_Prop)); - if (anElement.hasAttribute(FillMode_Prop)) - trace.setShowArea(true); - if (anElement.hasAttribute(Trace.ShowPoints_Prop)) - trace.setShowPoints(anElement.getAttributeBoolValue(Trace.ShowPoints_Prop)); - else if (anElement.hasAttribute("ShowSymbols")) - trace.setShowPoints(anElement.getAttributeBoolValue("ShowSymbols")); - if (anElement.hasAttribute(Trace.ShowTags_Prop)) - trace.setShowTags(anElement.getAttributeBoolValue(Trace.ShowTags_Prop)); - XMLElement pointStyleXML = anElement.getElement("PointStyle"); - if (pointStyleXML == null) - pointStyleXML = anElement.getElement("SymbolStyle"); - if (pointStyleXML != null) - trace.getPointStyle().fromXML(anArchiver, pointStyleXML); - XMLElement tagStyleXML = anElement.getElement("TagStyle"); - if (tagStyleXML != null) - trace.getTagStyle().fromXML(anArchiver, tagStyleXML); - - // Return this part - return this; - } } diff --git a/src/snapcharts/view/DataArea.java b/src/snapcharts/view/DataArea.java index 74cbe17..e1bda67 100644 --- a/src/snapcharts/view/DataArea.java +++ b/src/snapcharts/view/DataArea.java @@ -62,11 +62,6 @@ public DataArea(ChartHelper aChartHelper, Trace aTrace) */ public Trace getTrace() { return _trace; } - /** - * Returns the TraceStyle. - */ - public TraceStyle getTraceStyle() { return _trace.getTraceStyle(); } - /** * Returns whether trace is enabled. */ @@ -120,8 +115,8 @@ public TraceList getTraceList() */ public Color getDataColor() { - TraceStyle traceStyle = getTraceStyle(); - return traceStyle.getLineColor(); + Trace trace = getTrace(); + return trace.getLineColor(); } /** @@ -129,8 +124,8 @@ public Color getDataColor() */ public Color getColorMapColor(int anIndex) { - TraceStyle traceStyle = getTraceStyle(); - return traceStyle.getColorMapColor(anIndex); + Trace trace = getTrace(); + return trace.getColorMapColor(anIndex); } /** @@ -540,7 +535,7 @@ protected void chartPartDidChange(PropChange aPC) Object src = aPC.getSource(); String propName = aPC.getPropName(); Trace trace = getTrace(); - TraceStyle traceStyle = getTraceStyle(); + TraceStyle traceStyle = trace.getTraceStyle(); if (src == trace || src == traceStyle || src instanceof Axis || propName == Trace.Stacked_Prop) { clearStagedData(); } diff --git a/src/snapcharts/view/LegendEntryView.java b/src/snapcharts/view/LegendEntryView.java index 862690d..a2c06e0 100644 --- a/src/snapcharts/view/LegendEntryView.java +++ b/src/snapcharts/view/LegendEntryView.java @@ -13,9 +13,6 @@ public class LegendEntryView extends Label { // The Trace private Trace _trace; - // The TraceStyle - private TraceStyle _traceStyle; - // The PointStyle private PointStyle _pointStyle; @@ -29,7 +26,6 @@ public LegendEntryView(Legend aLegend, Trace aTrace) { super(); _trace = aTrace; - _traceStyle = aTrace.getTraceStyle(); _pointStyle = _trace.getPointStyle(); // Set ShowText @@ -96,7 +92,7 @@ protected double getPrefHeightImpl(double aW) // Get marked height of line/area/symbol double markedHeight = 0; if (_trace.isShowLine()) - markedHeight = _traceStyle.getLineWidth(); + markedHeight = _trace.getLineWidth(); if (_trace.isShowArea()) markedHeight += AREA_HEIGHT - markedHeight / 2; if (_trace.isShowPoints()) @@ -125,23 +121,23 @@ protected void paintFront(Painter aPntr) boolean showLine = _trace.isShowLine(); boolean showPoints = _trace.isShowPoints(); boolean disabled = _trace.isDisabled(); - double lineWidth = showLine ? _traceStyle.getLineWidth() : 0; + double lineWidth = showLine ? _trace.getLineWidth() : 0; double lineY = areaY + areaH / 2; if (showArea) lineY -= AREA_HEIGHT / 2; // Handle ShowArea if (showArea) { - Color fillColor = _traceStyle.getFillColor(); + Color fillColor = _trace.getFillColor(); double lineMidY = lineY + lineWidth / 2; aPntr.fillRectWithPaint(areaX, lineMidY, areaW, AREA_HEIGHT, fillColor); } // Handle ShowLine if (showLine) { - Color lineColor = _traceStyle.getLineColor(); + Color lineColor = _trace.getLineColor(); if (disabled) lineColor = DISABLED_COLOR; - Stroke lineStroke = _traceStyle.getLineStroke(); + Stroke lineStroke = _trace.getLineStroke(); aPntr.setColor(lineColor); aPntr.setStroke(lineStroke); aPntr.drawLine(areaX, lineY, areaX + areaW, lineY); diff --git a/src/snapcharts/view/ToolTipView.java b/src/snapcharts/view/ToolTipView.java index a6f486f..92fc76d 100644 --- a/src/snapcharts/view/ToolTipView.java +++ b/src/snapcharts/view/ToolTipView.java @@ -64,8 +64,7 @@ protected void reloadContentsNow() setPadding(5,5,10,5); // Create RowView: BulletView - TraceStyle traceStyle = trace.getTraceStyle(); - Color color = traceStyle.getLineColor(); + Color color = trace.getLineColor(); // If alt down, add index int pointIndex = dataPoint.getIndex(); @@ -92,7 +91,7 @@ protected void reloadContentsNow() DataChan chan = trace.getDataType().getChannel(i); Object val = trace.getValueForChannel(chan, pointIndex); String valStr = val instanceof String ? (String) val : _fmt.format(val); - String text = chan.toString() + ": " + valStr; + String text = chan + ": " + valStr; // Create label and add View entryView = createToolTipEntry(text); diff --git a/src/snapcharts/viewx/BarDataArea.java b/src/snapcharts/viewx/BarDataArea.java index ef3b7cb..d98389e 100644 --- a/src/snapcharts/viewx/BarDataArea.java +++ b/src/snapcharts/viewx/BarDataArea.java @@ -42,7 +42,12 @@ public BarDataArea(ChartHelper aChartHelper, Trace aTrace) public BarStyle getBarStyle() { if (_barStyle != null) return _barStyle; - return _barStyle = getChart().getTraceStyleHelper().getBarStyle(); + Trace trace = getTrace(); + TraceStyle traceStyle = trace.getTraceStyle(); + if (traceStyle instanceof BarStyle) + return _barStyle = (BarStyle) traceStyle; + System.err.println("BarDataArea.getBarStyle: Trace doesn't have BarStyle"); + return _barStyle = new TraceStyleHpr(trace).getBarStyle(); } /** @@ -100,8 +105,7 @@ protected Section[] getSections() double dispY = dataToViewY(dataY); // Draw bar - TraceStyle traceStyle = trace.getTraceStyle(); - Color color = colorTraces ? traceStyle.getLineColor() : getColorMapColor(i); + Color color = colorTraces ? trace.getLineColor() : getColorMapColor(i); double barX = i*sectionWidth + groupPadWidth + (j*2+1)*barPadWidth + j*barWidth; double barHeight = viewHeight - dispY; section.bars[j] = new Bar(dataPoint, barX, dispY, barWidth, barHeight, color); diff --git a/src/snapcharts/viewx/ContourChartHelper.java b/src/snapcharts/viewx/ContourChartHelper.java index 7b78ace..f11acaa 100644 --- a/src/snapcharts/viewx/ContourChartHelper.java +++ b/src/snapcharts/viewx/ContourChartHelper.java @@ -5,6 +5,7 @@ import snap.gfx.Painter; import snap.util.PropChange; import snapcharts.model.*; +import snapcharts.modelx.ContourStyle; import snapcharts.view.*; /** @@ -21,7 +22,19 @@ public class ContourChartHelper extends ChartHelper { public ContourChartHelper(ChartView aChartView) { super(aChartView); - _contourHelper = new ContourHelper(this); + + // This is bogus + Trace[] traces = aChartView.getTraceList().getTraces(); + for (Trace trace : traces) { + TraceStyle traceStyle = trace.getTraceStyle(); + if (traceStyle instanceof ContourStyle) { + _contourHelper = new ContourHelper(this, (ContourStyle) traceStyle); + break; + } + } + if (_contourHelper == null) { + System.err.println("ContourChartHelper.init: No Contour Trace!"); + } } /** diff --git a/src/snapcharts/viewx/ContourHelper.java b/src/snapcharts/viewx/ContourHelper.java index 89895c2..de8c72d 100644 --- a/src/snapcharts/viewx/ContourHelper.java +++ b/src/snapcharts/viewx/ContourHelper.java @@ -21,6 +21,9 @@ public class ContourHelper { // The ChartHelper private ChartHelper _chartHelper; + // The ContourStyle + private ContourStyle _contourStyle; + // The number of contour levels private int _levelsCount; @@ -33,19 +36,16 @@ public class ContourHelper { /** * Constructor. */ - public ContourHelper(ChartHelper aChartHelper) + public ContourHelper(ChartHelper aChartHelper, ContourStyle aContourStyle) { _chartHelper = aChartHelper; + _contourStyle = aContourStyle; } /** * Returns the ContourProps. */ - public ContourStyle getContourProps() - { - Chart chart = _chartHelper.getChart(); - return chart.getTraceStyleHelper().getContourStyle(); - } + public ContourStyle getContourProps() { return _contourStyle; } /** * Returns whether to show contour lines. diff --git a/src/snapcharts/viewx/Line3DSceneBuilder.java b/src/snapcharts/viewx/Line3DSceneBuilder.java index 3586ca9..c970686 100644 --- a/src/snapcharts/viewx/Line3DSceneBuilder.java +++ b/src/snapcharts/viewx/Line3DSceneBuilder.java @@ -10,7 +10,6 @@ import snap.gfx3d.Scene3D; import snapcharts.model.Trace; import snapcharts.model.TraceList; -import snapcharts.model.TraceStyle; import snapcharts.model.Intervals; import snapcharts.view.AxisViewX; @@ -82,8 +81,7 @@ protected void addLine3D(Trace aTrace, int anIndex, int aCount) { // Create 2d path Path path = createDataPath(aTrace); - TraceStyle traceStyle = aTrace.getTraceStyle(); - Color dataStrokeColor = traceStyle.getLineColor(); + Color dataStrokeColor = aTrace.getLineColor(); Color dataFillColor = dataStrokeColor.blend(Color.CLEARWHITE, .25); // Get depth, and Z values for back/front diff --git a/src/snapcharts/viewx/PieDataArea.java b/src/snapcharts/viewx/PieDataArea.java index a7aa3c7..17fedab 100644 --- a/src/snapcharts/viewx/PieDataArea.java +++ b/src/snapcharts/viewx/PieDataArea.java @@ -147,7 +147,7 @@ protected void paintDataArea(Painter aPntr) int selIndexLast = getSelPointLastIndex(); double reveal = getReveal(); double selPointMorph = getSelDataPointMorph(); - TraceStyle traceStyle = getTraceStyle(); + Trace trace = getTrace(); // Set font aPntr.setFont(getFont()); @@ -158,7 +158,7 @@ protected void paintDataArea(Painter aPntr) // Get loop wedge and color Wedge wedge = wedges[i]; - Color color = traceStyle.getColorMapColor(i); + Color color = trace.getColorMapColor(i); // If targeted, paint targ area if (i==targIndex && i!=selIndex) { diff --git a/src/snapcharts/viewx/PointPainter.java b/src/snapcharts/viewx/PointPainter.java index e159131..00a00d8 100644 --- a/src/snapcharts/viewx/PointPainter.java +++ b/src/snapcharts/viewx/PointPainter.java @@ -55,7 +55,6 @@ public void paintSymbolsAndTagsPrep() { // Get ShowSymbol info Trace trace = _dataArea.getTrace(); - TraceStyle traceStyle = _dataArea.getTraceStyle(); boolean showPoints = trace.isShowPoints(); PointStyle pointStyle = trace.getPointStyle(); int symbolSize = pointStyle.getSymbolSize(); @@ -84,9 +83,9 @@ public void paintSymbolsAndTagsPrep() // Get VisPointCount and MaxPointCount int visPointCount = endIndex - startIndex + 1; - int maxPointCount = traceStyle.getMaxPointCount(); - int skipPointCount = traceStyle.getSkipPointCount(); - int pointSpacing = traceStyle.getPointSpacing(); + int maxPointCount = pointStyle.getMaxPointCount(); + int skipPointCount = pointStyle.getSkipPointCount(); + int pointSpacing = pointStyle.getPointSpacing(); // Get point increment (as real number, so we can round to point index for distribution) double incrementReal = 1; diff --git a/src/snapcharts/viewx/PolarContourChartHelper.java b/src/snapcharts/viewx/PolarContourChartHelper.java index d22889b..3a21b28 100644 --- a/src/snapcharts/viewx/PolarContourChartHelper.java +++ b/src/snapcharts/viewx/PolarContourChartHelper.java @@ -1,6 +1,7 @@ package snapcharts.viewx; import snap.util.PropChange; import snapcharts.model.*; +import snapcharts.modelx.ContourStyle; import snapcharts.view.*; /** @@ -17,7 +18,19 @@ public class PolarContourChartHelper extends PolarChartHelper { public PolarContourChartHelper(ChartView aChartView) { super(aChartView); - _contourHelper = new ContourHelper(this); + + // This is bogus + Trace[] traces = aChartView.getTraceList().getTraces(); + for (Trace trace : traces) { + TraceStyle traceStyle = trace.getTraceStyle(); + if (traceStyle instanceof ContourStyle) { + _contourHelper = new ContourHelper(this, (ContourStyle) traceStyle); + break; + } + } + if (_contourHelper == null) { + System.err.println("PolarContourChartHelper.init: No Contour Trace!"); + } } /** diff --git a/src/snapcharts/viewx/PolarDataArea.java b/src/snapcharts/viewx/PolarDataArea.java index cdde343..0424bcd 100644 --- a/src/snapcharts/viewx/PolarDataArea.java +++ b/src/snapcharts/viewx/PolarDataArea.java @@ -99,9 +99,8 @@ protected void paintDataArea(Painter aPntr) double reveal = getReveal(); // Get style info - TraceStyle traceStyle = trace.getTraceStyle(); boolean showLine = trace.isShowLine(); - Stroke dataStroke = traceStyle.getLineStroke(); + Stroke dataStroke = trace.getLineStroke(); Color dataColor = getDataColor(); boolean showPoints = trace.isShowPoints(); diff --git a/src/snapcharts/viewx/XYDataArea.java b/src/snapcharts/viewx/XYDataArea.java index f5d6b22..b6ed2a2 100644 --- a/src/snapcharts/viewx/XYDataArea.java +++ b/src/snapcharts/viewx/XYDataArea.java @@ -78,14 +78,13 @@ protected void paintDataArea(Painter aPntr) // Get Trace info Trace trace = getTrace(); - TraceStyle traceStyle = getTraceStyle(); boolean showLine = trace.isShowLine(); boolean showPoints = trace.isShowPoints(); boolean showArea = trace.isShowArea(); // Get DataColor, DataStroke Color dataColor = getDataColor(); - Stroke dataStroke = traceStyle.getLineStroke(); + Stroke dataStroke = trace.getLineStroke(); // If reveal is not full (1) then clip double reveal = getReveal(); @@ -97,7 +96,7 @@ protected void paintDataArea(Painter aPntr) // If ShowArea, fill path, too if (showArea) { Shape dataAreaShape = getDataAreaShape(); - Color dataAreaColor = traceStyle.getFillColor(); + Color dataAreaColor = trace.getFillColor(); aPntr.setColor(dataAreaColor); aPntr.fill(dataAreaShape); } diff --git a/src/snapcharts/viewx/XYDataAreaShapes.java b/src/snapcharts/viewx/XYDataAreaShapes.java index 9e57626..c829cde 100644 --- a/src/snapcharts/viewx/XYDataAreaShapes.java +++ b/src/snapcharts/viewx/XYDataAreaShapes.java @@ -57,7 +57,7 @@ public DataLineShape(DataArea aDataArea, boolean isIncludeAll) { _dataArea = aDataArea; _includeAll = isIncludeAll; - _pointJoin = _dataArea.getTraceStyle().getPointJoin(); + _pointJoin = _dataArea.getTrace().getPointJoin(); } /** @@ -151,7 +151,7 @@ public DataLinePathIter(Transform aTrans, DataArea aDataArea, boolean isShowAll) _count = _endIndex - _startIndex + 1; // If PointJoin.Spline, we might need extra point to prevent jumping - PointJoin pointJoin = aDataArea.getTraceStyle().getPointJoin(); + PointJoin pointJoin = aDataArea.getTrace().getPointJoin(); if (pointJoin == PointJoin.Spline) { if (_startIndex > 0) _startIndex--; @@ -249,7 +249,7 @@ public DataAreaToZeroPathIter(Transform aTrans, DataArea aDataArea) _dataLinePathIter = dataLinePathIter; // Apply PointJoint PathIter, if needed - PointJoin pointJoin = aDataArea.getTraceStyle().getPointJoin(); + PointJoin pointJoin = aDataArea.getTrace().getPointJoin(); if (pointJoin != PointJoin.Line) _dataLinePathIter = XYPointJoins.getPathIterForPointJoin(pointJoin, _dataLinePathIter, aDataArea); @@ -339,7 +339,7 @@ public DataAreaToNextPathIter(Transform aTrans, DataArea aDataArea) _dataLinePathIter = new DataLinePathIter(aTrans, aDataArea, false); // Apply PointJoint PathIter, if needed - PointJoin pointJoin = _dataArea.getTraceStyle().getPointJoin(); + PointJoin pointJoin = _dataArea.getTrace().getPointJoin(); if (pointJoin != PointJoin.Line) _dataLinePathIter = XYPointJoins.getPathIterForPointJoin(pointJoin, _dataLinePathIter, aDataArea); @@ -386,7 +386,7 @@ public Seg getNext(double[] coords) _nextDataAreaPathIter = nextDataAreaPathIter; // Apply PointJoin if needed - PointJoin pointJoin = _nextDataArea.getTraceStyle().getPointJoin(); + PointJoin pointJoin = _nextDataArea.getTrace().getPointJoin(); PointJoin pointJoinReverse = pointJoin.getReverse(); // Turns HV to VH if (pointJoinReverse != PointJoin.Line) _nextDataAreaPathIter = XYPointJoins.getPathIterForPointJoin(pointJoinReverse, _nextDataAreaPathIter, _nextDataArea);