Examples of TableWriter


Examples of org.geotools.io.TableWriter

     */
    private void bursaWolfs(final PrintWriter out, final String[] args) throws FactoryException {
        final NumberFormat nf = NumberFormat.getNumberInstance();
        nf.setMinimumFractionDigits(3);
        nf.setMaximumFractionDigits(3);
        final TableWriter table = new TableWriter(out);
        table.writeHorizontalSeparator();
        final String[] titles = {
            Vocabulary.format(VocabularyKeys.TARGET),
            "dx", "dy", "dz", "ex", "ey", "ez", "ppm"
        };
        for (int i=0; i<titles.length; i++) {
            table.write(titles[i]);
            table.nextColumn();
            table.setAlignment(TableWriter.ALIGN_CENTER);
        }
        table.writeHorizontalSeparator();
        for (int i=0; i<args.length; i++) {
            IdentifiedObject object = factory.createObject(args[i]);
            if (object instanceof CoordinateReferenceSystem) {
                object = CRSUtilities.getDatum((CoordinateReferenceSystem) object);
            }
            if (object instanceof DefaultGeodeticDatum) {
                final BursaWolfParameters[] params =
                        ((DefaultGeodeticDatum) object).getBursaWolfParameters();
                for (int j=0; j<params.length; j++) {
                    final BursaWolfParameters p = params[j];
                    table.setAlignment(TableWriter.ALIGN_LEFT);
                    table.write(p.targetDatum.getName().getCode());
                    table.nextColumn();
                    table.setAlignment(TableWriter.ALIGN_RIGHT);
                    double v;
                    for (int k=0; k<7; k++) {
                        switch (k) {
                            case 0: v = p.dx;  break;
                            case 1: v = p.dy;  break;
                            case 2: v = p.dz;  break;
                            case 3: v = p.ex;  break;
                            case 4: v = p.ey;  break;
                            case 5: v = p.ez;  break;
                            case 6: v = p.ppm; break;
                            default: throw new AssertionError(k);
                        }
                        table.write(nf.format(v));
                        table.nextColumn();
                    }
                    table.nextLine();
                }
                table.writeHorizontalSeparator();
            }
        }
        try {
            table.flush();
        } catch (IOException e) {
            // Should never happen, since we are backed by PrintWriter
            throw new AssertionError(e);
        }
    }
View Full Code Here

Examples of org.geotools.io.TableWriter

     * @throws IOException if an error occured while writting to the output stream.
     */
    public void printDefinitions(final Writer out) throws IOException {
        final Locale locale = null;
        final Vocabulary resources = Vocabulary.getResources(locale);
        final TableWriter table = new TableWriter(out, TableWriter.SINGLE_VERTICAL_LINE);
        table.setMultiLinesCells(true);
        table.writeHorizontalSeparator();
        table.write(resources.getString(VocabularyKeys.NAME));
        table.nextColumn();
        table.write(resources.getString(VocabularyKeys.TYPE));
        table.nextColumn();
        table.write(resources.getString(VocabularyKeys.DESCRIPTION));
        table.nextLine();
        table.writeHorizontalSeparator();
        for (final Iterator it=definitions.entrySet().iterator(); it.hasNext();) {
            final Map.Entry entry = (Map.Entry) it.next();
            final Object   object = ((Definition) entry.getValue()).asObject;
            table.write(String.valueOf(entry.getKey()));
            table.nextColumn();
            table.write(Classes.getShortClassName(object));
            table.nextColumn();
            if (object instanceof IdentifiedObject) {
                table.write(((IdentifiedObject) object).getName().getCode());
            }
            table.nextLine();
        }
        table.writeHorizontalSeparator();
        table.flush();
    }
View Full Code Here

Examples of org.geotools.io.TableWriter

        if (locale == null) {
            locale = Locale.getDefault();
        }
        final NumberFormat source = getNumberFormat(locale, false);
        final NumberFormat target = getNumberFormat(locale, true);
        final TableWriter  table  = new TableWriter(out, TableWriter.SINGLE_VERTICAL_LINE);
        table.setAlignment(TableWriter.ALIGN_CENTER);
        table.writeHorizontalSeparator();
        try {
            final CoordinateSystem sourceCS = getSourceCRS().getCoordinateSystem();
            final CoordinateSystem targetCS = getTargetCRS().getCoordinateSystem();
            int dimension = sourceCS.getDimension();
            for (int i=0; i<dimension; i++) {
                table.write(sourceCS.getAxis(i).getName().getCode());
                table.nextColumn();
            }
            dimension = targetCS.getDimension();
            for (int i=0; i<dimension; i++) {
                table.write(targetCS.getAxis(i).getName().getCode());
                table.nextColumn();
            }
            table.writeHorizontalSeparator();
        } catch (FactoryException e) {
            /*
             * Ignore. The only consequences is that the table will not
             * contains a title line.
             */
        }
        table.setAlignment(TableWriter.ALIGN_RIGHT);
        for (final Iterator <MappedPosition> it=getMappedPositions().iterator(); it.hasNext();) {
            final MappedPosition mp = (MappedPosition) it.next();
            DirectPosition point = mp.getSource();
            int dimension = point.getDimension();
            for (int i=0; i<dimension; i++) {
                table.write(source.format(point.getOrdinate(i)));
                table.nextColumn();
            }
            point = mp.getTarget();
            dimension = point.getDimension();
            for (int i=0; i<dimension; i++) {
                table.write(target.format(point.getOrdinate(i)));
                table.nextColumn();
            }
            table.nextLine();
        }
        table.writeHorizontalSeparator();
        table.flush();
    }
View Full Code Here

Examples of org.geotools.io.TableWriter

     * Returns a string representation of this mapped position.
     *
     * @todo Consider using a {@link java.text.NumberFormat} instance.
     */
    public String toString() {
        final TableWriter table = new TableWriter(null, " ");
        table.write(Vocabulary.format(VocabularyKeys.SOURCE_POINT));
        table.write(':');
        int dimension = source.getDimension();
        for (int i=0; i<dimension; i++) {
            table.nextColumn();
            table.write(String.valueOf(source.getOrdinate(i)));
        }
        table.nextLine();
        table.write(Vocabulary.format(VocabularyKeys.TARGET_POINT));
        table.write(':');
        dimension = target.getDimension();
        for (int i=0; i<dimension; i++) {
            table.nextColumn();
            table.write(String.valueOf(target.getOrdinate(i)));
        }
        return table.toString();
    }
View Full Code Here

Examples of org.geotools.io.TableWriter

            } catch (FactoryException exception) {
                failures.put(code, exception.getLocalizedMessage());
            }
        }
        if (!failures.isEmpty()) {
            final TableWriter writer = new TableWriter(out, " ");
            for (final Map.Entry<String,String> entry : failures.entrySet()) {
                writer.write(entry.getKey());
                writer.write(':');
                writer.nextColumn();
                writer.write(entry.getValue());
                writer.nextLine();
            }
            try {
                writer.flush();
            } catch (IOException e) {
                // Should not happen, since we are writting to a PrintWriter
                throw new AssertionError(e);
            }
        }
View Full Code Here

Examples of org.geotools.io.TableWriter

     * Executes the "{@code print crs}" instruction.
     */
    private void printCRS() throws FactoryException, IOException {
        final Locale locale = null;
        final Vocabulary resources = Vocabulary.getResources(locale);
        final TableWriter table = new TableWriter(out, TableWriter.SINGLE_VERTICAL_LINE);
        table.setMultiLinesCells(true);
        char separator = TableWriter.SINGLE_HORIZONTAL_LINE;
        if (sourceCRS!=null || targetCRS!=null) {
            table.writeHorizontalSeparator();
            table.write(resources.getString(VocabularyKeys.SOURCE_CRS));
            table.nextColumn();
            table.write(resources.getString(VocabularyKeys.TARGET_CRS));
            table.nextLine();
            table.writeHorizontalSeparator();
            if (sourceCRS != null) {
                table.write(parser.format(sourceCRS));
            }
            table.nextColumn();
            if (targetCRS != null) {
                table.write(parser.format(targetCRS));
            }
            table.nextLine();
            separator = TableWriter.DOUBLE_HORIZONTAL_LINE;
        }
        /*
         * Format the math transform and its inverse, if any.
         */
        update();
        if (transform != null) {
            table.nextLine(separator);
            table.write(resources.getString(VocabularyKeys.MATH_TRANSFORM));
            table.nextColumn();
            table.write(resources.getString(VocabularyKeys.INVERSE_TRANSFORM));
            table.nextLine();
            table.writeHorizontalSeparator();
            table.write(parser.format(transform));
            table.nextColumn();
            try {
                table.write(parser.format(transform.inverse()));
            } catch (NoninvertibleTransformException exception) {
                table.write(exception.getLocalizedMessage());
            }
            table.nextLine();
        }
        table.writeHorizontalSeparator();
        table.flush();
    }
View Full Code Here

Examples of org.geotools.io.TableWriter

     * Returns a string representation of this parameter. The default implementation
     * delegates the work to {@link #write}, which should be overridden by subclasses.
     */
    @Override
    public final String toString() {
        final TableWriter table = new TableWriter(null, 1);
        table.setMultiLinesCells(true);
        try {
            write(table);
        } catch (IOException exception) {
            // Should never happen, since we write to a StringWriter.
            throw new AssertionError(exception);
        }
        return table.toString();
    }
View Full Code Here

Examples of org.geotools.io.TableWriter

             * then the previous block. Reminder: the above 'instanceof' check for interface, not
             * for subclass. This explain why we use it instead of method overriding.
             */
            table.write(':');
            table.nextColumn();
            TableWriter inner = null;
            for (final Iterator it=((ParameterValueGroup) this).values().iterator(); it.hasNext();) {
                final GeneralParameterValue value = (GeneralParameterValue) it.next();
                if (value instanceof AbstractParameter) {
                    if (inner == null) {
                        inner = new TableWriter(table, 1);
                    }
                    ((AbstractParameter) value).write(inner);
                } else {
                    // Unknow implementation. It will break the formatting. Too bad...
                    if (inner != null) {
                        inner.flush();
                        inner = null;
                    }
                    table.write(value.toString());
                    table.write(System.getProperty("line.separator", "\r"));
                }
            }
            if (inner != null) {
                inner.flush();
            }
        } else {
            /*
             * No know parameter value for this default implementation.
             */
 
View Full Code Here

Examples of org.geotools.io.TableWriter

                }
            }
        }
        final Locale locale = null;
        final Vocabulary resources = Vocabulary.getResources(locale);
        final TableWriter table = new TableWriter(out, 0);
        table.setMultiLinesCells(true);
        table.writeHorizontalSeparator();
        table.setAlignment(TableWriter.ALIGN_RIGHT);
        if (sourcePosition != null) {
            table.write(resources.getLabel(VocabularyKeys.SOURCE_POINT));
            print(sourcePosition,    table);
            print(transformedSource, table);
            table.nextLine();
        }
        if (targetPosition != null) {
            table.write(resources.getLabel(VocabularyKeys.TARGET_POINT));
            print(transformedTarget, table);
            print(targetPosition,    table);
            table.nextLine();
        }
        if (sourceCRS!=null && targetCRS!=null) {
            table.write(resources.getLabel(VocabularyKeys.DISTANCE));
            printDistance(sourceCRS, sourcePosition, transformedTarget, table);
            printDistance(targetCRS, targetPosition, transformedSource, table);
            table.nextLine();
        }
        table.writeHorizontalSeparator();
        table.flush();
        if (targetException != null) {
            out.write(targetException);
            out.write(lineSeparator);
        }
    }
View Full Code Here

Examples of org.geotools.io.TableWriter

     * Returns a string representation of the current state of this calculator.
     */
    @Override
    public String toString() {
        final Vocabulary resources = Vocabulary.getResources(null);
        final TableWriter buffer = new TableWriter(null, " ");
        if (coordinateReferenceSystem != null) {
            buffer.write(resources.getLabel(VocabularyKeys.COORDINATE_REFERENCE_SYSTEM));
            buffer.nextColumn();
            buffer.write(coordinateReferenceSystem.getName().getCode());
            buffer.nextLine();
        }
        if (ellipsoid != null) {
            buffer.write(resources.getLabel(VocabularyKeys.ELLIPSOID));
            buffer.nextColumn();
            buffer.write(ellipsoid.getName().getCode());
            buffer.nextLine();
        }
        final CoordinateFormat cf = new CoordinateFormat();
        final Format           nf = cf.getFormat(0);
        if (true) {
            buffer.write(resources.getLabel(VocabularyKeys.SOURCE_POINT));
            buffer.nextColumn();
            buffer.write(format(cf, long1, lat1));
            buffer.nextLine();
        }
        if (destinationValid) {
            buffer.write(resources.getLabel(VocabularyKeys.TARGET_POINT));
            buffer.nextColumn();
            buffer.write(format(cf, long2, lat2));
            buffer.nextLine();
        }
        if (directionValid) {
            buffer.write(resources.getLabel(VocabularyKeys.AZIMUTH));
            buffer.nextColumn();
            buffer.write(nf.format(new Angle(toDegrees(azimuth))));
            buffer.nextLine();
        }
        if (directionValid) {
            buffer.write(resources.getLabel(VocabularyKeys.ORTHODROMIC_DISTANCE));
            buffer.nextColumn();
            buffer.write(nf.format(distance));
            if (ellipsoid != null) {
                buffer.write(' ');
                buffer.write(ellipsoid.getAxisUnit().toString());
            }
            buffer.nextLine();
        }
        return buffer.toString();
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.