Search in sources :

Example 1 with ImageGraphics2D

use of org.freehep.graphicsio.ImageGraphics2D in project polyGembler by c-zhou.

the class HMMPanel method propertyChange.

public synchronized void propertyChange(PropertyChangeEvent arg0) {
    String nme = arg0.getPropertyName();
    /*if(nme.equals("emiss")){
        if(plot<2 && Constants.plot()<2) return;

	   Object[] obj = (Object[]) arg0.getNewValue();

	   StateDistribution dist = (StateDistribution) obj[0];
	   Integer l = (Integer) obj[1];
	   if(l==0) clear();
	   Integer i = (Integer)obj[2];
	   this.addInformation(dist,i);
   }*/
    if (nme.equals("setToPlot")) {
        int level = (Integer) arg0.getNewValue();
        setToPlot(level);
        return;
    }
    if (nme.equals("done")) {
        // this.update();
        try {
            ip.setMinimumSize(dim);
            ip.setSize(dim);
            ratePanel.setSize(dim);
            int lp_height = locP.getSize().height;
            if (Constants.printPlots() && plot == 2) {
                {
                    System.err.println("printing hmm");
                    // int maxSNPS =Constants.maxSNPS();
                    // int n = (int) Math.ceil((double) this.noSnps/ maxSNPS);
                    // for(int i=0; i<n; i++){
                    // for(int j=0; j<this.getTabCount(); j++){
                    Properties p = new Properties();
                    p.setProperty("PageSize", "A4");
                    boolean inclLocP = false;
                    // int len1 = maxSNPS;//Math.min(maxSNPS, location.size()  - i*maxSNPS);
                    Dimension dim1 = new Dimension(dim.width, dim.height + this.ratePanel.getHeight() + (inclLocP ? lp_height : 0));
                    AffineTransform at = new AffineTransform();
                    ImageGraphics2D g = new ImageGraphics2D(new File(this.chartBF, "hmm.png"), dim1, ImageConstants.PNG);
                    g.setProperties(p);
                    g.startExport();
                    at.setToTranslation(0, 0);
                    g.setTransform(at);
                    this.ip.print(g);
                    at.setToTranslation(0, dim.height);
                    g.setTransform(at);
                    this.ratePanel.print(g);
                    if (inclLocP) {
                        at.setToTranslation(0, dim.height + ratePanel.getHeight());
                        g.setTransform(at);
                        this.locP.print(g);
                    }
                    g.endExport();
                    System.err.println("done printing hmm");
                // }
                // }
                }
                if (false) {
                    Properties p = new Properties();
                    p.setProperty("PageSize", "A4");
                    ChartPanel cp = (ChartPanel) this.ratePanel.getComponent(0);
                    cp.setSize(dim);
                    ImageGraphics2D g = new ImageGraphics2D(new File(this.chartBF, "rates.png"), cp, ImageConstants.PNG);
                    g.setProperties(p);
                    g.startExport();
                    cp.print(g);
                    g.endExport();
                }
            }
        } catch (Exception exc) {
            exc.printStackTrace();
        }
    }
    /* if(nme.equals("init")){

    }
    else if(nme.equals("emiss")){

    }

    else 
    else if(nme.equals("expec_i")){

    }
    else if(nme.equals("expectation1")){

      //  this.updateUI();
    }
    else if(nme.equals("dist_maximisation")){

    }
    else*/
    if (nme.equals("hmm_maximisation")) {
        update();
    }
// else throw new RuntimeException("!! "+nme);
}
Also used : ImageGraphics2D(org.freehep.graphicsio.ImageGraphics2D) ChartPanel(org.jfree.chart.ChartPanel) AffineTransform(java.awt.geom.AffineTransform) Dimension(java.awt.Dimension) Properties(java.util.Properties) File(java.io.File)

Example 2 with ImageGraphics2D

use of org.freehep.graphicsio.ImageGraphics2D in project polyGembler by c-zhou.

the class HMMSplitPanel method propertyChange.

public synchronized void propertyChange(PropertyChangeEvent arg0) {
    String nme = arg0.getPropertyName();
    /*if(nme.equals("emiss")){
        if(plot<2 && Constants.plot()<2) return;

	   Object[] obj = (Object[]) arg0.getNewValue();

	   StateDistribution dist = (StateDistribution) obj[0];
	   Integer l = (Integer) obj[1];
	   if(l==0) clear();
	   Integer i = (Integer)obj[2];
	   this.addInformation(dist,i);
   }*/
    if (nme.equals("setToPlot")) {
        int level = (Integer) arg0.getNewValue();
        setToPlot(level);
        return;
    }
    if (nme.equals("done")) {
        // this.update();
        try {
            ip.setMinimumSize(dim);
            ip.setSize(dim);
            ratePanel.setSize(dim);
            int lp_height = locP.getSize().height;
            if (Constants.printPlots() && plot == 2) {
                {
                    System.err.println("printing hmm");
                    // int maxSNPS =Constants.maxSNPS();
                    // int n = (int) Math.ceil((double) this.noSnps/ maxSNPS);
                    // for(int i=0; i<n; i++){
                    // for(int j=0; j<this.getTabCount(); j++){
                    Properties p = new Properties();
                    p.setProperty("PageSize", "A4");
                    boolean inclLocP = false;
                    // int len1 = maxSNPS;//Math.min(maxSNPS, location.size()  - i*maxSNPS);
                    Dimension dim1 = new Dimension(dim.width, dim.height + this.ratePanel.getHeight() + (inclLocP ? lp_height : 0));
                    AffineTransform at = new AffineTransform();
                    ImageGraphics2D g = new ImageGraphics2D(new File(this.chartBF, "hmm.png"), dim1, ImageConstants.PNG);
                    g.setProperties(p);
                    g.startExport();
                    at.setToTranslation(0, 0);
                    g.setTransform(at);
                    this.ip.print(g);
                    at.setToTranslation(0, dim.height);
                    g.setTransform(at);
                    this.ratePanel.print(g);
                    if (inclLocP) {
                        at.setToTranslation(0, dim.height + ratePanel.getHeight());
                        g.setTransform(at);
                        this.locP.print(g);
                    }
                    g.endExport();
                    System.err.println("done printing hmm");
                // }
                // }
                }
                if (false) {
                    Properties p = new Properties();
                    p.setProperty("PageSize", "A4");
                    ChartPanel cp = (ChartPanel) this.ratePanel.getComponent(0);
                    cp.setSize(dim);
                    ImageGraphics2D g = new ImageGraphics2D(new File(this.chartBF, "rates.png"), cp, ImageConstants.PNG);
                    g.setProperties(p);
                    g.startExport();
                    cp.print(g);
                    g.endExport();
                }
            }
        } catch (Exception exc) {
            exc.printStackTrace();
        }
    }
    /* if(nme.equals("init")){

    }
    else if(nme.equals("emiss")){

    }

    else 
    else if(nme.equals("expec_i")){

    }
    else if(nme.equals("expectation1")){

      //  this.updateUI();
    }
    else if(nme.equals("dist_maximisation")){

    }
    else*/
    if (nme.equals("hmm_maximisation")) {
        update();
    }
// else throw new RuntimeException("!! "+nme);
}
Also used : ImageGraphics2D(org.freehep.graphicsio.ImageGraphics2D) ChartPanel(org.jfree.chart.ChartPanel) AffineTransform(java.awt.geom.AffineTransform) Dimension(java.awt.Dimension) Properties(java.util.Properties) File(java.io.File)

Example 3 with ImageGraphics2D

use of org.freehep.graphicsio.ImageGraphics2D in project abstools by abstools.

the class ExporterImpl method getGraphics.

private VectorGraphics getGraphics() {
    VectorGraphics vectorGraphics;
    if (orientation == null) {
        orientation = dim.getWidth() <= dim.getHeight() ? "Portrait" : "Landscape";
    }
    if (type.equals("gif")) {
        vectorGraphics = new GIFGraphics2D(stream, dim);
    } else if (type.equals("png")) {
        vectorGraphics = new ImageGraphics2D(stream, dim, "png");
    } else if (type.equals("bmp")) {
        vectorGraphics = new ImageGraphics2D(stream, dim, "bmp");
    } else if (type.equals("jpg")) {
        vectorGraphics = new ImageGraphics2D(stream, dim, "jpg");
    } else if (type.equals("pdf")) {
        PDFGraphics2D pdf = new PDFGraphics2D(stream, dim);
        Properties properties = new Properties();
        properties.setProperty(PDFGraphics2D.ORIENTATION, orientation);
        properties.setProperty(PDFGraphics2D.PAGE_SIZE, format);
        pdf.setProperties(properties);
        vectorGraphics = pdf;
    } else if (type.equals("ps")) {
        PSGraphics2D ps = new PSGraphics2D(stream, dim);
        Properties properties = new Properties();
        properties.setProperty(PSGraphics2D.ORIENTATION, orientation);
        properties.setProperty(PSGraphics2D.PAGE_SIZE, format);
        ps.setProperties(properties);
        ps.setMultiPage(true);
        vectorGraphics = ps;
    } else if (type.equals("emf")) {
        vectorGraphics = new EMFGraphics2D(stream, dim);
    } else if (type.equals("svg")) {
        vectorGraphics = new SVGGraphics2D(stream, dim);
    } else if (type.equals("swf")) {
        vectorGraphics = new SWFGraphics2D(stream, dim);
    } else {
        throw new IllegalArgumentException("Unknown type: " + type);
    }
    return vectorGraphics;
}
Also used : EMFGraphics2D(org.freehep.graphicsio.emf.EMFGraphics2D) ImageGraphics2D(org.freehep.graphicsio.ImageGraphics2D) PDFGraphics2D(org.freehep.graphicsio.pdf.PDFGraphics2D) GIFGraphics2D(org.freehep.graphicsio.gif.GIFGraphics2D) SVGGraphics2D(org.freehep.graphicsio.svg.SVGGraphics2D) SWFGraphics2D(org.freehep.graphicsio.swf.SWFGraphics2D) PSGraphics2D(org.freehep.graphicsio.ps.PSGraphics2D) Properties(java.util.Properties) VectorGraphics(org.freehep.graphics2d.VectorGraphics)

Example 4 with ImageGraphics2D

use of org.freehep.graphicsio.ImageGraphics2D in project abstools by abstools.

the class ExporterImpl method createGraphics.

@Override
protected Graphics2D createGraphics() {
    dim = new Dimension(getWidth(), getHeight());
    vg = getGraphics();
    if (vg instanceof ImageGraphics2D) {
        vg.setColor(Color.WHITE);
        vg.fillRect(0, 0, getWidth(), getHeight());
    }
    return vg;
}
Also used : ImageGraphics2D(org.freehep.graphicsio.ImageGraphics2D) Dimension(java.awt.Dimension)

Aggregations

ImageGraphics2D (org.freehep.graphicsio.ImageGraphics2D)4 Dimension (java.awt.Dimension)3 Properties (java.util.Properties)3 AffineTransform (java.awt.geom.AffineTransform)2 File (java.io.File)2 ChartPanel (org.jfree.chart.ChartPanel)2 VectorGraphics (org.freehep.graphics2d.VectorGraphics)1 EMFGraphics2D (org.freehep.graphicsio.emf.EMFGraphics2D)1 GIFGraphics2D (org.freehep.graphicsio.gif.GIFGraphics2D)1 PDFGraphics2D (org.freehep.graphicsio.pdf.PDFGraphics2D)1 PSGraphics2D (org.freehep.graphicsio.ps.PSGraphics2D)1 SVGGraphics2D (org.freehep.graphicsio.svg.SVGGraphics2D)1 SWFGraphics2D (org.freehep.graphicsio.swf.SWFGraphics2D)1