Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle class 9 #1

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
Open

Handle class 9 #1

wants to merge 16 commits into from

Conversation

jpprade
Copy link

@jpprade jpprade commented Jan 28, 2021

Preliminary support for class 9 object, which contains HOTSPOT.

Jean-Philippe Prade added 8 commits January 28, 2021 14:14
This class hold several data but one in particular : HOTSPOT.
ApplicationStructureAttribute is supported, flag are ignored for now
Adding getter & setter & making a class public, to be able to get it
outside of the library.

The goal is to access HOTSPOT data to render them separately
@philippecade
Copy link
Member

Thank you for contributing, I appreciate. I see that the commits keep on coming, will you let me know when you are ready to complete this pull request?
Thanks.

Jean-Philippe Prade added 2 commits June 1, 2021 15:48
- for CAP alignement not sure if it is technicaly good, but visualy it
is
- for begin and end figure

these are needed, because there is an issue with this lib : the filling
of polybezier is never done.

I noticed that Polybezier which are inside figure, are closed shape, and
so a Genaralpath must be used instead of a basic shape.


I added a error message warning the user when encoutering a tiff
@jpprade
Copy link
Author

jpprade commented Jun 9, 2021

Hello, I am close to perfection, I have still a few issue remaining : a couples of files are crashing when reading bytes.

they also make this lib crash :
https://github.com/BhaaLseN/CgmInfo

I suspect something wrong with the files itself, but Isoview can display them so I am searching.

I have alse another issue to fix but I don't know what is the best way :

The lib doesn't handle filling polybezier, all polybezier are drawn as "path".

I figured out that when polybezier are inside "FIGURE" the shape must be closed and filled (with GeneralPath)

@ishanuda
Copy link

Hi,

This is a great library to work with and I see the recent changes.
Wouldn't it be nice to introduce an enum for the relevant types?

public enum ApplicationStructureAttributeType {
    /**
     * Initial value: none
     * Applies to: 'grobject', 'para', 'subpara'
     * Inherited: no
     */
    REGION,
    /**
     * Initial value: none
     * Applies to: 'grobject', 'para', 'subpara'
     * Inherited: no
     */
    VIEWCONTEXT,
    /**
     * Initial value: none
     * Applies to: 'grobject', 'para', 'subpara'
     * Inherited: no
     */
    LINKURI,
    /**
     * Initial value: none
     * Applies to: 'layer'
     * Inherited: no
     */
    LAYERNAME,
    /**
     * Initial value: none
     * Applies to: 'layer'
     * Inherited: no
     */
    LAYERDESC,
    /**
     * Initial value: none
     * Applies to: 'grobject', 'para', 'subpara'
     * Inherited: no
     */
    SCREENTIP,
    /**
     * Initial value: none
     * Applies to: 'grobject', 'para', 'subpara'
     * Inherited: no
     */
    NAME,
    /**
     * Initial value: none
     * Applies to: 'para', 'subpara'
     * Inherited: no
     */
    CONTENT,
    /**
     * Initial value: on
     * Applies to: 'layer', 'grobject', 'para', 'subpara'
     * Inherited: yes
     */
    VISIBILITY,
    /**
     * Initial value: on
     * Applies to: 'layer', 'grobject', 'para', 'subpara'
     * Inherited: yes
     */
    INTERACTIVITY;
    
    public static ApplicationStructureAttributeType getType(String type) {
        switch(type) {
            case "region":
                return REGION;
            case "viewcontext":
                return VIEWCONTEXT;
            case "linkuri":
                return LINKURI;
            case "layername":
                return LAYERNAME;
            case "layerdesc":
                return LAYERDESC;
            case "screentip":
                return SCREENTIP;
            case "name":
                return NAME;
            case "content":
                return CONTENT;
            case "visibility":
                return VISIBILITY;
            case "interactivity":
                return INTERACTIVITY;
            default: {
                System.out.println("unsupported attribute type: " + type);
                return REGION;
            }
        }
    }
    
}

public class ApplicationStructureAttribute extends Command {
            
    /** attribute type */
    private String type;
    
    private ApplicationStructureAttributeType attributeType;
    
    protected StructuredDataRecord sdr;
    
    public ApplicationStructureAttribute(int ec, int eid, int l, DataInput in) 
        throws IOException 
    {
        super(ec, eid, l, in);
        this.type = makeString();
        this.attributeType = ApplicationStructureAttributeType.getType(type);
        this.sdr = makeSDR();
    }

    public String getType() {
        return type;
    }
    
    public ApplicationStructureAttributeType getAttributeType() {
        return attributeType;
    }

    public StructuredDataRecord getSdr() {
        return sdr;
    }
    
    @Override
    public void paint(CGM2SVG d) {
        int currentApsIndex = d.getCurrentApsIndex();
        ApplicationStructure aps = d.getApsStack().get(currentApsIndex);
        aps.getApsAttribs().add(this);
    }
    
    @Override
    public String toString() {
        return "ApplicationStructureAttribute: " 
            + "[type: " + this.type +"]" 
            + "[sdr: " + this.sdr + "]";
    }
    
}

And in the Command Class:

case APPLICATION_STRUCTURE_ELEMENTS: // 9
                // unsupported(ec, eid);
                // return new Command(ec, eid, l, in);
                return readApplicationStructureElements(in, ec, eid, l);
public enum ApplicationStructureDescriptorElements {
    UNUSED_0(0),
    APPLICATION_STRUCTURE_ATTRIBUTE(1);
    
    private final int elementCode;

    ApplicationStructureDescriptorElements(int ec) {
        elementCode = ec;
    }
    
    public static ApplicationStructureDescriptorElements getElement(int ec) {
        if (ec < 0 || ec >= values().length) {
            throw new ArrayIndexOutOfBoundsException(ec);
        }

        return values()[ec];
    }

    public int getElementCode() {
        return elementCode;
    }

    @Override
    public String toString() {
        return name().concat("(").concat(String.valueOf(elementCode)).concat(")");
    }
}

// Class: 9

    private static Command readApplicationStructureElements(DataInput in, int ec, int eid, int l) 
        throws IOException 
    {
        switch(ApplicationStructureDescriptorElements.getElement(eid)) {
            case APPLICATION_STRUCTURE_ATTRIBUTE: 
                return new ApplicationStructureAttribute(ec, eid, l, in);
            default: 
                unsupported(ec, eid);
                return new Command(ec, eid, l, in);
        }
    }

Thank you verymuch

Shan

Jean-Philippe Prade added 3 commits July 15, 2021 20:59
Possibility to access hatchtype to overload
Hatch type can be negative in my samples

protection on Tile element when there is more data than image resolution
@philippecade
Copy link
Member

Thank you for all your contributions.

However this pull request now contains so many different things that it will be hard to integrate as it. Would it be possible to split this pull request into some more individual features? This would increase the visibility of things.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants