eclipse / eavp

Eclipse advanced visualization project
Eclipse Public License 1.0
9 stars 15 forks source link

Refactoring XYZSeriesStyle class #153

Closed anarak closed 5 years ago

anarak commented 7 years ago

Any suggestions what to do with this class for refactoring which contains only swt and nebula libraries?

jayjaybillings commented 7 years ago

We can't refactor XYZSeriesStyle, but let me look at the class that uses it (assuming ISeries) real quick.

SmithRWORNL commented 7 years ago

For my two cents, I think the styles are poorly categorized. Other than AbstractSeriesStyle, all the individual styles are completely tied to the xygraph implementation for the CSV service.

My vote would be to put ISeriesStyle and AbstractSeriesStyle in o.e.e.viz.service.styles and for all other styles to be moved to the new CSV service bundle, possibly with new names that better reflect their use (ie CSVAxisStyle or XYGraphAxisStyle instead of the ambiguous XYZAxisStyle.)

jayjaybillings commented 7 years ago

Okay, we don't need to rewrite it, but it should be moved. Whatever bundle you are moving the RCP stuff to should get the XYZ*Style.java files. Basically, what @SmithRWORNL said, but put it in an RCP-specific bundle or bundle fragment.

I'm thinking about the best way to update CSVSeries. Gimme a minute.

jayjaybillings commented 7 years ago

So, it looks to me like line 93 in the main constructor is not necessary:

    protected CSVSeries(EventList<Double> source, Color color) {
        super(source);
        style = new XYZSeriesStyle(color); // Why call this when we have ISeries.setStyle(IStyle)?
        time = 0;
        parent = null;
        label = "unlabeled series";
    }

As I note in my highlight, why create a concrete style when creating CSVSeries when ISeries has a setStyle() operation that CSVSeries implements? I think we should delete that line and update EAVP, if necessary, to always call setStyle() instead of relying on a hard-coded, concretely-typed, encapsulation-violating default.

anarak commented 7 years ago

@SmithRWORNL did you mean to create a new bundle o.e.e.viz.service.styles and move ISeriesStyle and AbstractSeriesStyle there? How about instead leaving them where they are now, but move all other CSV specific realizations to the style package within already agreed to be created bundle o.e.e.viz.service.scv? I think it is better to leave them where they are now because the *.service bundle is meant to contain abstract code.

Also, it seems that only CSV service uses SeriesStyle realizations, because of that I'd just omit XYZ from the names of the classes to make AxisStyle, etc. Or, CSVAxisStyle if needs to be.

jayjaybillings commented 7 years ago

We need the XYZSeriesStyle classes to maintain the XYZ part of the name. This is a normal class naming convention to expose the implementation in the name for concrete classes.

@anarak is correct that the interfaces and abstract classes should stay in the current bundle. Here's the structure I want:

SmithRWORNL commented 7 years ago

@anarak o.e.e.viz.service.styles already exists as a package inside of o.e.e.viz.service, where it should stay, containing the interface and abstract class.

I believe everything but ISeriesStyle and AbstractSeriesStyle are not just CSV specific, but also RCP specific thanks to being implemented specifically for XYGraph, and so would be best placed in o.e.e.viz.service.csv.rcp.

Names like CSVAxisStyle would be best, as we may reuse the ISeriesStyles in the future, such as for the SWTChart service.

anarak commented 7 years ago

@jayjaybillings removing line 93 from constructor might help in CSVSeries, but we will need to set the style later anyway, in CSVPlot for example, which we are trying to dissect too.

anarak commented 7 years ago

@SmithRWORNL I was confused by your wording, you said to

"put ISeriesStyle and AbstractSeriesStyle in o.e.e.viz.service.styles"

they are already there. Now I understand what you meant.

jayjaybillings commented 7 years ago

@anarak Yes, that is correct. We will probably have to inject this on the handler. So, for example, our IPlotHandler interface would have an operation like getStyle() or, if we wanted to create multiple styles dynamically, getStyleFactory() and our SWTCSVPlotHandler would return XYZSeriesStyle instances or an appropriate factory.

SmithRWORNL commented 5 years ago

The old CSVVizService will be replaced in 0.3