package jas.hist; import jas.plot.DataArea; import jas.plot.EditableLabel; import jas.plot.Legend; import jas.plot.MovableObject; import jas.plot.Title; import jas.util.ColorConverter; import jas.util.ScientificFormat; import jas.util.xml.XMLWriter; import java.awt.Color; import java.awt.Component; import java.awt.Font; import java.io.Writer; import java.util.Enumeration; import javax.swing.BorderFactory; import javax.swing.border.Border; import javax.swing.border.LineBorder; final class XMLPrintWriter extends XMLWriter { XMLPrintWriter(Writer w) { super(w); } void print(JASHist plot,boolean snapshot) { printPlotHeader(); Title t = plot.getTitleObject(); if (t != null && t.isVisible()) print(t); print(plot.getLegend(),plot.getShowLegend()); StatisticsBlock s = plot.getStats(); if (s != null && s.isVisible()) print(s); DataArea d = plot.getDataArea(); if (d != null && d.isVisible()) print(d,plot.getDataManager(),snapshot); setAttribute("width",plot.getWidth()); setAttribute("height",plot.getHeight()); printTag("bounds"); printColorScheme(plot); printPlotFooter(); } void printColorScheme(Component c) { Component pp = c.getParent(); Color fg = c.getForeground(); Color bg = c.getBackground(); if (pp == null || fg != pp.getForeground() || bg != pp.getBackground()) { if (pp == null || fg != pp.getForeground()) setAttribute("foregroundColor",ColorConverter.colorToString(fg)); if (pp == null || bg != pp.getBackground()) setAttribute("backgroundColor",ColorConverter.colorToString(bg)); printTag("colorScheme"); } } void print(Title t) { openTag("title"); print(t.getInsideBorder()); printBounds(t); print(t.getLabel()); printColorScheme(t); closeTag(); } void print(JASHistAxis a, String p_location) { int type = a.getAxisType(); setAttribute("location",p_location); setAttribute("type",convertAxisTypeToString(type)); setAttribute("showOverflows",a.getShowOverflows()); if (a.isBinned()) setAttribute("numberOfBins",a.getBins()); if (type != a.STRING) { setAttribute("logarithmic",a.isLogarithmic()); setAttribute("allowSuppressedZero",a.getAllowSuppressedZero()); if (!a.getRangeAutomatic()) { setAttribute("min",a.getMin()); setAttribute("max",a.getMax()); } } openTag("axis"); EditableLabel label = a.getLabelObject(); if (label != null) print(label); print(a.getFont()); closeTag(); } void print(EditableLabel label) { setAttribute("text",label.getText()); openTag("label"); print(label.getFont()); closeTag(); } void print(Legend legend,int visibility) { setAttribute("visible",convertLegendToString(visibility)); openTag("legend"); if (legend != null && legend.isVisible()) { print(legend.getInsideBorder()); printBounds(legend); printColorScheme(legend); print(legend.getFont()); int n = legend.getNEntries(); for (int i=0; i