List of usage examples for java.awt.geom AffineTransform getTranslateX
public double getTranslateX()
From source file:org.vfny.geoserver.global.xml.XMLConfigWriter.java
protected static void storeCoverage(CoverageInfoDTO cv, File dir) throws ConfigurationException { if (LOGGER.isLoggable(Level.FINE)) { LOGGER.fine("In method storeCoverage"); }/* w w w.j a v a 2s .com*/ File f = WriterUtils.initWriteFile(new File(dir, "info.xml"), false); try { Writer fw = new OutputStreamWriter(new FileOutputStream(f), getDefaultEncoding()); WriterHelper cw = new WriterHelper(fw); Map m = new HashMap(); if ((cv.getFormatId() != null) && (cv.getFormatId() != "")) { m.put("format", cv.getFormatId()); } cw.openTag("coverage", m); if ((cv.getName() != null) && (cv.getName() != "")) { cw.textTag("name", cv.getName()); } if ((cv.getLabel() != null) && (cv.getLabel() != "")) { cw.textTag("label", cv.getLabel()); } if ((cv.getDescription() != null) && (cv.getDescription() != "")) { cw.textTag("description", cv.getDescription()); } if ((cv.getWmsPath() != null) && (cv.getWmsPath() != "")) { cw.textTag("wmspath", cv.getWmsPath()); } m = new HashMap(); if ((cv.getMetadataLink() != null)) { m.put("about", cv.getMetadataLink().getAbout()); m.put("type", cv.getMetadataLink().getType()); m.put("metadataType", cv.getMetadataLink().getMetadataType()); cw.openTag("metadataLink", m); cw.writeln(cv.getMetadataLink().getContent()); cw.closeTag("metadataLink"); } if ((cv.getKeywords() != null) && (cv.getKeywords().size() != 0)) { String s = ""; Iterator i = cv.getKeywords().iterator(); if (i.hasNext()) { s = i.next().toString(); while (i.hasNext()) { s = s + "," + i.next().toString(); } } cw.textTag("keywords", s); } if ((cv.getDefaultStyle() != null) && (cv.getDefaultStyle() != "")) { cw.comment("the default style this CoverageInfoDTO can be represented by.\n" + "at least must contain the \"default\" attribute "); m = new HashMap(); m.put("default", cv.getDefaultStyle()); final ArrayList styles = cv.getStyles(); if (styles.isEmpty()) { cw.attrTag("styles", m); } else { cw.openTag("styles", m); Iterator s_IT = styles.iterator(); while (s_IT.hasNext()) cw.textTag("style", (String) s_IT.next()); cw.closeTag("styles"); } } // // // storing the envelope. // The native crs wkt is stored as the crs attribute. The user defined srs identifier as // the srsName atribute // // if (cv.getEnvelope() != null) { GeneralEnvelope e = cv.getEnvelope(); m = new HashMap(); String userDefinedCrsIdentifier = cv.getUserDefinedCrsIdentifier(); if ((userDefinedCrsIdentifier != null) && (userDefinedCrsIdentifier != "")) { m.put("srsName", userDefinedCrsIdentifier); } String nativeCrsWkt = cv.getNativeCrsWKT(); m.put("crs", nativeCrsWkt.replaceAll("\"", "'").replaceAll("\r\n", "\n")); if (!e.isNull()) { cw.comment("crs: native CRS definition, srsName: user defined CRS identifier"); cw.openTag("envelope", m); cw.textTag("pos", e.getLowerCorner().getOrdinate(0) + " " + e.getLowerCorner().getOrdinate(1)); cw.textTag("pos", e.getUpperCorner().getOrdinate(0) + " " + e.getUpperCorner().getOrdinate(1)); cw.closeTag("envelope"); } } // // // AlFa: storing the grid-geometry // // if (cv.getGrid() != null) { GridGeometry g = cv.getGrid(); MathTransform tx = g.getGridToCRS(); InternationalString[] dimNames = cv.getDimensionNames(); m = new HashMap(); m.put("dimension", new Integer(g.getGridRange().getDimension())); String lowers = ""; String upers = ""; for (int r = 0; r < g.getGridRange().getDimension(); r++) { lowers += (g.getGridRange().getLow(r) + " "); upers += (g.getGridRange().getHigh(r) + " "); } cw.openTag("grid", m); cw.textTag("low", lowers); cw.textTag("high", upers); if (dimNames != null) { for (int dn = 0; dn < dimNames.length; dn++) cw.textTag("axisName", dimNames[dn].toString()); } // // // AlFa: storing geo-transform // // if (tx instanceof AffineTransform) { AffineTransform aTX = (AffineTransform) tx; cw.openTag("geoTransform"); cw.textTag("scaleX", String.valueOf(aTX.getScaleX())); cw.textTag("scaleY", String.valueOf(aTX.getScaleY())); cw.textTag("shearX", String.valueOf(aTX.getShearX())); cw.textTag("shearY", String.valueOf(aTX.getShearY())); cw.textTag("translateX", String.valueOf(aTX.getTranslateX())); cw.textTag("translateY", String.valueOf(aTX.getTranslateY())); cw.closeTag("geoTransform"); } cw.closeTag("grid"); } if (cv.getDimensions() != null) { CoverageDimension[] dims = cv.getDimensions(); for (int d = 0; d < dims.length; d++) { Double[] nulls = dims[d].getNullValues(); cw.openTag("CoverageDimension"); cw.textTag("name", dims[d].getName()); cw.textTag("description", dims[d].getDescription()); if (dims[d].getRange() != null) { cw.openTag("interval"); cw.textTag("min", Double.toString(dims[d].getRange().getMinimum(true))); cw.textTag("max", Double.toString(dims[d].getRange().getMaximum(true))); cw.closeTag("interval"); } else { cw.openTag("interval"); cw.textTag("min", Double.toString(Double.NEGATIVE_INFINITY)); cw.textTag("max", Double.toString(Double.POSITIVE_INFINITY)); cw.closeTag("interval"); } if (nulls != null) { cw.openTag("nullValues"); for (int n = 0; n < nulls.length; n++) { cw.textTag("value", nulls[n].toString()); } cw.closeTag("nullValues"); } cw.closeTag("CoverageDimension"); } } cw.openTag("supportedCRSs"); if ((cv.getRequestCRSs() != null) && (cv.getRequestCRSs().size() != 0)) { String s = ""; Iterator i = cv.getRequestCRSs().iterator(); if (i.hasNext()) { s = i.next().toString(); while (i.hasNext()) { s = s + "," + i.next().toString(); } } cw.textTag("requestCRSs", s); } if ((cv.getResponseCRSs() != null) && (cv.getResponseCRSs().size() != 0)) { String s = ""; Iterator i = cv.getResponseCRSs().iterator(); if (i.hasNext()) { s = i.next().toString(); while (i.hasNext()) { s = s + "," + i.next().toString(); } } cw.textTag("responseCRSs", s); } cw.closeTag("supportedCRSs"); m = new HashMap(); if ((cv.getNativeFormat() != null) && (cv.getNativeFormat() != "")) { m.put("nativeFormat", cv.getNativeFormat()); } cw.openTag("supportedFormats", m); if ((cv.getSupportedFormats() != null) && (cv.getSupportedFormats().size() != 0)) { String s = ""; Iterator i = cv.getSupportedFormats().iterator(); if (i.hasNext()) { s = i.next().toString(); while (i.hasNext()) { s = s + "," + i.next().toString(); } } cw.textTag("formats", s); } cw.closeTag("supportedFormats"); m = new HashMap(); if ((cv.getDefaultInterpolationMethod() != null) && (cv.getDefaultInterpolationMethod() != "")) { m.put("default", cv.getDefaultInterpolationMethod()); } cw.openTag("supportedInterpolations", m); if ((cv.getInterpolationMethods() != null) && (cv.getInterpolationMethods().size() != 0)) { String s = ""; Iterator i = cv.getInterpolationMethods().iterator(); if (i.hasNext()) { s = i.next().toString(); while (i.hasNext()) { s = s + "," + i.next().toString(); } } cw.textTag("interpolationMethods", s); } cw.closeTag("supportedInterpolations"); // /////////////////////////////////////////////////////////////////////// // // STORING READ PARAMETERS // // /////////////////////////////////////////////////////////////////////// if ((cv.getParameters() != null) && (cv.getParameters().size() != 0)) { cw.openTag("parameters"); final Iterator i = cv.getParameters().keySet().iterator(); final HashMap temp = new HashMap(); while (i.hasNext()) { String key = (String) i.next(); if (cv.getParameters().get(key) != null) { temp.put("name", key); temp.put("value", cv.getParameters().get(key).toString().replaceAll("\"", "'")); } cw.attrTag("parameter", temp); } cw.closeTag("parameters"); } cw.closeTag("coverage"); fw.close(); } catch (IOException e) { throw new ConfigurationException(e); } }
From source file:uky.article.imageviewer.views.SWTImageCanvas.java
/** * Synchronize the scrollbar with the image. If the transform is out * of range, it will correct it. This function considers only following * factors :<b> transform, image size, client area</b>. *//* w w w.j a va2s . c o m*/ public void syncScrollBars() { if (sourceImage == null) { redraw(); return; } AffineTransform af = transform; double sx = af.getScaleX(), sy = af.getScaleY(); double tx = af.getTranslateX(), ty = af.getTranslateY(); if (tx > 0) tx = 0; if (ty > 0) ty = 0; ScrollBar horizontal = getHorizontalBar(); horizontal.setIncrement(getClientArea().width / 100); horizontal.setPageIncrement(getClientArea().width); Rectangle imageBound = sourceImage.getBounds(); int cw = getClientArea().width, ch = getClientArea().height; if (imageBound.width * sx > cw) { /* image is wider than client area */ horizontal.setMaximum((int) (imageBound.width * sx)); horizontal.setEnabled(true); if (((int) -tx) > horizontal.getMaximum() - cw) tx = -horizontal.getMaximum() + cw; } else { /* image is narrower than client area */ horizontal.setEnabled(false); tx = (cw - imageBound.width * sx) / 2; //center if too small. } horizontal.setSelection((int) (-tx)); horizontal.setThumb((getClientArea().width)); ScrollBar vertical = getVerticalBar(); vertical.setIncrement(getClientArea().height / 100); vertical.setPageIncrement((getClientArea().height)); if (imageBound.height * sy > ch) { /* image is higher than client area */ vertical.setMaximum((int) (imageBound.height * sy)); vertical.setEnabled(true); if (((int) -ty) > vertical.getMaximum() - ch) ty = -vertical.getMaximum() + ch; } else { /* image is less higher than client area */ vertical.setEnabled(false); ty = (ch - imageBound.height * sy) / 2; //center if too small. } vertical.setSelection((int) (-ty)); vertical.setThumb((getClientArea().height)); /* update transform. */ af = AffineTransform.getScaleInstance(sx, sy); af.preConcatenate(AffineTransform.getTranslateInstance(tx, ty)); transform = af; redraw(); }