Skip to content

Commit

Permalink
Trace: Moved ShowLine, ShowArea, ShowPoints, ShowTags, PointStyle, Ta…
Browse files Browse the repository at this point in the history
…gStyle here from TraceStyle

Trace: Added ShowArea
  • Loading branch information
reportmill committed Nov 19, 2021
1 parent ca78414 commit 6445f4e
Show file tree
Hide file tree
Showing 27 changed files with 381 additions and 323 deletions.
20 changes: 3 additions & 17 deletions src/snapcharts/app/ChartPaneInsp.java
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,6 @@ public void initUI()
_traceInsp = new TraceInsp(_chartPane);
addInspector(_traceInsp, false);

// Create/add DataStyleInsp
//_traceStyleInsp = new TraceStyleInsp(_chartPane);
//addInspector(_traceStyleInsp, false);

// Set all inspectors
_allInspectors = new ChartPartInsp[] { _chartInsp, _headerInsp, _axisInsp, _contourAxisInsp,
_dataViewInsp, _legendInsp, _markerInsp, _traceInsp };
Expand All @@ -161,16 +157,6 @@ public void initUI()
_miscInsp = new MiscInsp(_chartPane);
}

/**
* Override to trigger update of DataStyleInsp.
*/
@Override
protected void initShowing()
{
//if (_traceStyleInsp != null)
// _traceStyleInsp.resetLater();
}

/**
* Adds an inspector.
*/
Expand Down Expand Up @@ -285,11 +271,11 @@ public void chartPartInspLabelMousePress(ChartPartInsp anInsp)
// Get ChartPart for inspector
ChartPart chartPart = anInsp.getChartPart();

// DataStyleInsp/DataStyle is going to pretend to represent DataSetList
// TraceInsp/Trace is going to pretend to represent TraceList
if (chartPart instanceof TraceStyle) {
Chart chart = _chartPane.getChart();
TraceList dataList = chart.getTraceList();
chartPart = dataList.getTraceCount() > 0 ? dataList.getTrace(0) : chart;
TraceList traceList = chart.getTraceList();
chartPart = traceList.getTraceCount() > 0 ? traceList.getTrace(0) : chart;
}

// Set new ChartPane.SelChartPart
Expand Down
2 changes: 1 addition & 1 deletion src/snapcharts/app/ChartPaneSel.java
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ private ChartPartView getChartPartViewForPart(ChartPart aChartPart)
return markerView;
}

// Handle DataStyle
// Handle Trace
if (aChartPart instanceof TraceList || aChartPart instanceof Trace)
return _chartView.getDataView();

Expand Down
6 changes: 3 additions & 3 deletions src/snapcharts/appmisc/OpenInPlotly.java
Original file line number Diff line number Diff line change
Expand Up @@ -303,15 +303,15 @@ private void writeTrace(Trace aTrace, int anIndex)
traceJS.addKeyValue("stackgroup", "one");

// If ShowArea, add: fill: 'tozeroy'
if (traceStyle.isShowArea() && !aTrace.isStacked())
if (aTrace.isShowArea() && !aTrace.isStacked())
traceJS.addKeyValue("fill", "tozeroy");

// If ChartType.SCATTER, add: mode: 'markers'
if (chartType == ChartType.SCATTER || chartType == ChartType.POLAR) {

// Set mode: lines | markers | lines+markers
boolean isShowLine = traceStyle.isShowLine();
boolean isShowPoints = traceStyle.isShowPoints();
boolean isShowLine = aTrace.isShowLine();
boolean isShowPoints = aTrace.isShowPoints();
String modeStr = isShowLine && isShowPoints ? "lines+markers" :
isShowLine ? "lines" : isShowPoints ? "markers" : "";
traceJS.addKeyValue("mode", modeStr);
Expand Down
4 changes: 2 additions & 2 deletions src/snapcharts/apptools/ContourStyleInsp.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public ContourStyleInsp(ChartPane aChartPane)
*/
protected void resetUI()
{
// Get DataStyle
// Get TraceStyle
TraceStyle traceStyle = getChart().getTraceStyle();
ContourStyle contourStyle = traceStyle instanceof ContourStyle ? (ContourStyle) traceStyle : null;
if (contourStyle == null) return;
Expand All @@ -51,7 +51,7 @@ protected void resetUI()
*/
protected void respondUI(ViewEvent anEvent)
{
// Get DataStyle
// Get TraceStyle
TraceStyle traceStyle = getChart().getTraceStyle();
ContourStyle contourStyle = traceStyle instanceof ContourStyle ? (ContourStyle) traceStyle : null;
if (contourStyle == null) return;
Expand Down
8 changes: 5 additions & 3 deletions src/snapcharts/apptools/TraceAreaStyleInsp.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,12 @@ protected void initUI()
*/
protected void resetUI()
{
// Get TraceStyle
// Get Trace, TraceStyle
Trace trace = getTrace(); if (trace == null) return;
TraceStyle traceStyle = getTraceStyle(); if (traceStyle == null) return;

// Reset ShowAreaCheckBox
boolean showArea = traceStyle.isShowArea();
boolean showArea = trace.isShowArea();
setViewValue("ShowAreaCheckBox", showArea);

// Reset FillColorButton, FillColorResetButton
Expand All @@ -95,12 +96,13 @@ protected void resetUI()
protected void respondUI(ViewEvent anEvent)
{
// Get TraceStyle
Trace trace = getTrace(); if (trace == null) return;
TraceStyle traceStyle = getTraceStyle(); if (traceStyle == null) return;

// Handle ShowAreaCheckBox, FillModeComboBox
if (anEvent.equals("ShowAreaCheckBox")) {
boolean showArea = anEvent.getBoolValue();
traceStyle.setShowArea(showArea);
trace.setShowArea(showArea);
}

// Handle FillColorButton, FillColorResetButton
Expand Down
31 changes: 14 additions & 17 deletions src/snapcharts/apptools/TraceInsp.java
Original file line number Diff line number Diff line change
Expand Up @@ -168,11 +168,10 @@ protected void resetUI()
setViewValue("TagsStyleButton", _currentInsp == _tagStyleInsp);

// Reset fonts
TraceStyle traceStyle = trace.getTraceStyle();
setButtonHighlight("LineStyleButton", traceStyle.isShowLine());
setButtonHighlight("AreaStyleButton", traceStyle.isShowArea());
setButtonHighlight("PointsStyleButton", traceStyle.isShowPoints());
setButtonHighlight("TagsStyleButton", traceStyle.isShowTags());
setButtonHighlight("LineStyleButton", trace.isShowLine());
setButtonHighlight("AreaStyleButton", trace.isShowArea());
setButtonHighlight("PointsStyleButton", trace.isShowPoints());
setButtonHighlight("TagsStyleButton", trace.isShowTags());

// Update child inspector
ChartPartInsp chartTypeInsp = getCurrentInspector();
Expand All @@ -181,7 +180,7 @@ protected void resetUI()
chartTypeInsp.resetLater();

// Update SpacingInsp.Visible
boolean isPointsOrTags = traceStyle.isShowPoints() || traceStyle.isShowTags();
boolean isPointsOrTags = trace.isShowPoints() || trace.isShowTags();
boolean isPointsOrTagsInsp = _currentInsp == _pointStyleInsp || _currentInsp == _tagStyleInsp;
boolean isShowSpacing = isPointsOrTags && isPointsOrTagsInsp;
_spacingInsp.getUI().setVisible(isShowSpacing);
Expand Down Expand Up @@ -249,26 +248,25 @@ protected void respondUI(ViewEvent anEvent)
trace.setShowLegendEntry(anEvent.getBoolValue());

// Handle LineStyleButton, AreaStyleButton, PointsStyleButton, TagsStyleButton
TraceStyle traceStyle = trace.getTraceStyle();
if (anEvent.equals("LineStyleButton")) {
setCurrentInspector(_lineStyleInsp);
if (anEvent.getParentEvent() != null && anEvent.getParentEvent().getClickCount() == 2)
traceStyle.setShowLine(!traceStyle.isShowLine());
trace.setShowLine(!trace.isShowLine());
}
if (anEvent.equals("AreaStyleButton")) {
setCurrentInspector(_areaStyleInsp);
if (anEvent.getParentEvent() != null && anEvent.getParentEvent().getClickCount() == 2)
traceStyle.setShowArea(!traceStyle.isShowArea());
trace.setShowArea(!trace.isShowArea());
}
if (anEvent.equals("PointsStyleButton")) {
setCurrentInspector(_pointStyleInsp);
if (anEvent.getParentEvent() != null && anEvent.getParentEvent().getClickCount() == 2)
traceStyle.setShowPoints(!traceStyle.isShowPoints());
trace.setShowPoints(!trace.isShowPoints());
}
if (anEvent.equals("TagsStyleButton")) {
setCurrentInspector(_tagStyleInsp);
if (anEvent.getParentEvent() != null && anEvent.getParentEvent().getClickCount() == 2)
traceStyle.setShowTags(!traceStyle.isShowTags());
trace.setShowTags(!trace.isShowTags());
}
}

Expand Down Expand Up @@ -378,18 +376,17 @@ public void setSelected(boolean aValue)

// If first call, initialize Line/Area/Point inspector to primary trace painting
Trace trace = getTrace();
TraceStyle traceStyle = trace != null ? trace.getTraceStyle() : null;
if (_currentInsp == null && traceStyle != null) {
if (traceStyle.isShowLine())
if (_currentInsp == null && trace != null) {
if (trace.isShowLine())
setCurrentInspector(_lineStyleInsp);
else if (traceStyle.isShowArea())
else if (trace.isShowArea())
setCurrentInspector(_areaStyleInsp);
else if (traceStyle.isShowPoints())
else if (trace.isShowPoints())
setCurrentInspector(_pointStyleInsp);
}

// Update SpacingInsp.Visible
boolean isPointsOrTags = traceStyle != null && (traceStyle.isShowPoints() || traceStyle.isShowTags());
boolean isPointsOrTags = trace != null && (trace.isShowPoints() || trace.isShowTags());
boolean isPointsOrTagsInsp = _currentInsp == _pointStyleInsp || _currentInsp == _tagStyleInsp;
boolean isShowSpacing = isPointsOrTags && isPointsOrTagsInsp;
_spacingInsp.getUI().setVisible(isShowSpacing);
Expand Down
8 changes: 5 additions & 3 deletions src/snapcharts/apptools/TraceLineStyleInsp.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,11 @@ protected void initUI()
protected void resetUI()
{
// Get TraceStyle
Trace trace = getTrace(); if (trace == null) return;
TraceStyle traceStyle = getTraceStyle(); if (traceStyle == null) return;

// Reset ShowLineCheckBox
boolean showLine = traceStyle.isShowLine();
boolean showLine = trace.isShowLine();
setViewValue("ShowLineCheckBox", showLine);

// Reset LineColorButton, LineColorResetButton
Expand Down Expand Up @@ -121,14 +122,15 @@ protected void resetUI()
protected void respondUI(ViewEvent anEvent)
{
// Get TraceStyle
Trace trace = getTrace(); if (trace == null) return;
TraceStyle traceStyle = getTraceStyle(); if (traceStyle == null) return;

// Handle ShowLineCheckBox
if (anEvent.equals("ShowLineCheckBox")) {
boolean showLine = anEvent.getBoolValue();
traceStyle.setShowLine(showLine);
trace.setShowLine(showLine);
if (!showLine)
traceStyle.setShowPoints(true);
trace.setShowPoints(true);
}

// Handle LineWidthText, LineWidthAdd1Button, LineWidthSub1Button, LineWidthResetButton
Expand Down
18 changes: 9 additions & 9 deletions src/snapcharts/apptools/TracePointStyleInsp.java
Original file line number Diff line number Diff line change
Expand Up @@ -88,15 +88,15 @@ protected void initUI()
*/
protected void resetUI()
{
// Get TraceStyle
TraceStyle traceStyle = getTraceStyle(); if (traceStyle == null) return;
// Get Trace
Trace trace = getTrace(); if (trace == null) return;

// Reset ShowPointsCheckBox
boolean showPoints = traceStyle.isShowPoints();
boolean showPoints = trace.isShowPoints();
setViewValue("ShowPointsCheckBox", showPoints);

// Reset SymbolColorButton, SymbolColorResetButton
PointStyle pointStyle = traceStyle.getPointStyle();
PointStyle pointStyle = trace.getPointStyle();
Color symbolColor = pointStyle.getFillColor();
setViewValue("SymbolColorButton", symbolColor);
setViewVisible("SymbolColorResetButton", pointStyle.isFillSet());
Expand Down Expand Up @@ -129,16 +129,16 @@ protected void resetUI()
*/
protected void respondUI(ViewEvent anEvent)
{
// Get TraceStyle, PointStyle
TraceStyle traceStyle = getTraceStyle(); if (traceStyle == null) return;
PointStyle pointStyle = traceStyle.getPointStyle();
// Get Trace, PointStyle
Trace trace = getTrace(); if (trace == null) return;
PointStyle pointStyle = trace.getPointStyle();

// Handle ShowPointsCheckBox
if (anEvent.equals("ShowPointsCheckBox")) {
boolean showPoints = anEvent.getBoolValue();
traceStyle.setShowPoints(showPoints);
trace.setShowPoints(showPoints);
if (!showPoints)
traceStyle.setShowLine(true);
trace.setShowLine(true);
_traceInsp.resetLater();
}

Expand Down
16 changes: 8 additions & 8 deletions src/snapcharts/apptools/TraceTagStyleInsp.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,15 @@ protected void initUI()
*/
protected void resetUI()
{
// Get TraceStyle
TraceStyle traceStyle = getTraceStyle(); if (traceStyle == null) return;
// Get Trace
Trace trace = getTrace(); if (trace == null) return;

// Reset ShowTagsCheckBox
boolean showTags = traceStyle.isShowTags();
boolean showTags = trace.isShowTags();
setViewValue("ShowTagsCheckBox", showTags);

// Reset TagFontText, TagFontResetButton
TagStyle tagStyle = traceStyle.getTagStyle();
TagStyle tagStyle = trace.getTagStyle();
Font tagFont = tagStyle.getFont();
String fontName = tagFont.getName() + ' ' + FormatUtils.formatNum(tagFont.getSize());
setViewValue("TagFontText", fontName);
Expand Down Expand Up @@ -125,14 +125,14 @@ protected void resetUI()
*/
protected void respondUI(ViewEvent anEvent)
{
// Get TraceStyle, TagStyle
TraceStyle traceStyle = getTraceStyle(); if (traceStyle == null) return;
TagStyle tagStyle = traceStyle.getTagStyle();
// Get Trace, TagStyle
Trace trace = getTrace(); if (trace == null) return;
TagStyle tagStyle = trace.getTagStyle();

// Handle ShowTagsCheckBox
if (anEvent.equals("ShowTagsCheckBox")) {
boolean showTags = anEvent.getBoolValue();
traceStyle.setShowTags(showTags);
trace.setShowTags(showTags);
_traceInsp.resetLater();
}

Expand Down
2 changes: 1 addition & 1 deletion src/snapcharts/doc/DocTextReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ private void readDataSetKeyVal(String aKey, String aVal)
break;

case "ShowSymbols":
_trace.getTraceStyle().setShowPoints(SnapUtils.boolValue(aVal));
_trace.setShowPoints(SnapUtils.boolValue(aVal));
break;

case "DataX":
Expand Down
12 changes: 6 additions & 6 deletions src/snapcharts/model/PointStyle.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
*/
public class PointStyle extends ChartPart {

// The TraceStyle that holds this PointStyle
private TraceStyle _traceStyle;
// The Trace that holds this PointStyle
private Trace _trace;

// The Symbol Size
private int _symbolSize = DEFAULT_SYMBOL_SIZE;
Expand All @@ -38,10 +38,10 @@ public class PointStyle extends ChartPart {
/**
* Constructor.
*/
public PointStyle(TraceStyle aTraceStyle)
public PointStyle(Trace aTrace)
{
super();
_traceStyle = aTraceStyle;
_trace = aTrace;
}

/**
Expand Down Expand Up @@ -92,7 +92,7 @@ public Symbol getSymbol()
*/
private Color getDefaultLineColor()
{
return _traceStyle.getLineColor();
return _trace.getTraceStyle().getLineColor();
}

/**
Expand All @@ -102,7 +102,7 @@ private Color getDefaultFillColor()
{
if (getLineWidth() > 0 && !isLineColorSet())
return Color.WHITE;
return _traceStyle.getDefaultLineColor();
return _trace.getTraceStyle().getDefaultLineColor();
}

/**
Expand Down
8 changes: 4 additions & 4 deletions src/snapcharts/model/TagStyle.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
public class TagStyle extends ChartPart {

// The Trace that holds this TagStyle
private TraceStyle _traceStyle;
private Trace _trace;

// Constants for property defaults
public static final Font DEFAULT_TAG_FONT = Font.Arial10;
Expand All @@ -24,10 +24,10 @@ public class TagStyle extends ChartPart {
/**
* Constructor.
*/
public TagStyle(TraceStyle aTraceStyle)
public TagStyle(Trace aTrace)
{
super();
_traceStyle = aTraceStyle;
_trace = aTrace;
}

/**
Expand Down Expand Up @@ -55,7 +55,7 @@ public Object getPropDefault(String aPropName)
switch (aPropName) {

// Handle LineColor
case LineColor_Prop: return _traceStyle.getLineColor();
case LineColor_Prop: return _trace.getTraceStyle().getLineColor();

// Handle LineColor
case Fill_Prop: return getDefaultFill();
Expand Down
Loading

0 comments on commit 6445f4e

Please sign in to comment.