PathVisio / libGPML

Java library for reading / writing GPML files
Apache License 2.0
2 stars 4 forks source link

Should we restore StaticProperty.java for fireObjectModified()? #11

Closed Finterly closed 3 years ago

Finterly commented 3 years ago

@egonw

The old code has a class for "Static properties for ObjectTypes, linked in PathwayElement". We had removed this class since we took a more object oriented approach. However these static properties are used in the

fireObjectModifiedEvent(PathwayElementEvent.createSinglePropertyEvent(this, StaticProperty.TEXTLABEL));

fireObjectModifiedEvent() seems to be similar to public void firePropertyChange(String propertyName, int oldValue, int newValue).

What is the reason for the need of a String propertyName or StaticProperty? It seems to be necessary for updating listeners and tracking properties. Therefore, we would need to also define these StaticProperties again?

    public void fireObjectModifiedEvent(PathwayElementEvent e) {
        if (noFire > 0) {
            noFire -= 1;
            return;
        }
        if (parent != null)
            parent.childModified(e);
        for (PathwayElementListener g : listeners) {
            g.gmmlObjectModified(e);
        }
    }
....

    protected static PathwayElementEvent createSinglePropertyEvent(PathwayElement pwe, Object property) {
        return new PathwayElementEvent(pwe, property, false);
    }

    /**
     * Constructor.
     *
     * @param elem the PathwayElement that's been modified
     * @param prop the Property on the element that's been modified
     * @param coordinateChange Flag to indicate this event applies to a coordinate change.
     */
    private PathwayElementEvent(PathwayElement elem, Object prop, boolean coordinateChange) {
        pwElement = elem;
        property = prop;
        this.coordinateChange = coordinateChange;
    }
Finterly commented 3 years ago

will investigate further. closing question for now.