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);
}
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);
}
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;
}
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;
}
Aggregations