Package org.geotools.io

Examples of org.geotools.io.TableWriter$Cell


     * @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


        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

     * 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

            } 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

     * 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

     * 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

             * 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

                }
            }
        }
        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

     * 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

        Collections.sort(categories, this);
        /*
         * Prints the table header.
         */
        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.FACTORY));
        table.nextColumn();
        table.write(resources.getString(VocabularyKeys.AUTHORITY));
        table.nextColumn();
        table.write(resources.getString(VocabularyKeys.VENDOR));
        table.nextColumn();
        table.write(resources.getString(VocabularyKeys.IMPLEMENTATIONS));
        table.nextLine();
        table.nextLine(TableWriter.DOUBLE_HORIZONTAL_LINE);
        final StringBuilder vendors         = new StringBuilder();
        final StringBuilder implementations = new StringBuilder();
        for (final Iterator<Class<?>> it=categories.iterator(); it.hasNext();) {
            /*
             * Writes the category name (CRSFactory, DatumFactory, etc.)
             */
            final Class<?> category = it.next();
            table.write(Classes.getShortName(category));
            table.nextColumn();
            /*
             * Writes the authorities in a single cell. Same for vendors and implementations.
             */
            final Iterator<?> providers = registry.getServiceProviders(category, null, null);
            while (providers.hasNext()) {
                if (implementations.length() != 0) {
                    table          .write ('\n');
                    vendors        .append('\n');
                    implementations.append('\n');
                }
                final Factory provider = (Factory) providers.next();
                final Citation vendor = provider.getVendor();
                vendors.append(vendor.getTitle().toString(locale));
                implementations.append(Classes.getShortClassName(provider));
                if (provider instanceof AuthorityFactory) {
                    final Citation authority = ((AuthorityFactory) provider).getAuthority();
                    final Iterator<? extends Identifier> identifiers =
                            authority.getIdentifiers().iterator();
                    final String identifier = identifiers.hasNext()
                            ? identifiers.next().getCode().toString()
                            : authority.getTitle().toString(locale);
                    table.write(identifier);
                }
            }
            /*
             * Writes the vendors.
             */
            table.nextColumn();
            table.write(vendors.toString());
            vendors.setLength(0);
            /*
             * Writes the implementation class name.
             */
            table.nextColumn();
            table.write(implementations.toString());
            implementations.setLength(0);
            table.writeHorizontalSeparator();
        }
        table.flush();
    }
View Full Code Here

TOP

Related Classes of org.geotools.io.TableWriter$Cell

Copyright © 2018 www.massapicom. 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.