Exemplo n.º 1
0
  @SuppressWarnings("unchecked")
  private static Style createStyle(SimpleFeatureSource source, String fieldName) throws Exception {

    StyleFactory styleFactory = CommonFactoryFinder.getStyleFactory();
    FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2();

    Function colourFn = ff.function("colorlookup", ff.literal(source), ff.property(fieldName));

    Stroke stroke =
        styleFactory.createStroke(
            colourFn,
            ff.literal(1.0f), // line
            // width
            ff.literal(1.0f)); // opacity

    Fill fill = styleFactory.createFill(colourFn, ff.literal(1.0f)); // opacity

    Class<?> geomClass = source.getSchema().getGeometryDescriptor().getType().getBinding();
    Symbolizer sym = null;
    Geometries geomType = Geometries.getForBinding((Class<? extends Geometry>) geomClass);

    switch (geomType) {
      case POLYGON:
      case MULTIPOLYGON:
        sym = styleFactory.createPolygonSymbolizer(stroke, fill, null);
        break;

      case LINESTRING:
      case MULTILINESTRING:
        sym = styleFactory.createLineSymbolizer(stroke, null);
        break;

      case POINT:
      case MULTIPOINT:
        Graphic gr = styleFactory.createDefaultGraphic();
        gr.graphicalSymbols().clear();
        Mark mark = styleFactory.getCircleMark();
        mark.setFill(fill);
        mark.setStroke(stroke);
        gr.graphicalSymbols().add(mark);
        gr.setSize(ff.literal(10.0f));
        sym = styleFactory.createPointSymbolizer(gr, null);
        break;

      default:
        throw new IllegalArgumentException("Unsupported geometry type");
    }

    Style style = SLD.wrapSymbolizers(sym);

    return style;
  }
Exemplo n.º 2
0
  void jbInit() throws Exception {
    //
    pmIcon_ = new PlotMarkIcon(1);
    {
      String[] tempString = new String[3];
      tempString[0] = "NO_HEAD";
      tempString[1] = "HEAD";
      tempString[2] = "SCALED_HEAD";
      for (int i = 0; i < tempString.length; i++) {
        vectorStyleCBM.addElement(tempString[i]);
      }
    }
    {
      String[] tempString = new String[2];
      tempString[0] = "NO_MARK";
      tempString[1] = "MARK";
      for (int i = 0; i < tempString.length; i++) {
        originStyleCBM.addElement(tempString[i]);
      }
    }
    {
      String[] tempString = new String[3];
      tempString[0] = "BUTT";
      tempString[1] = "ROUND";
      tempString[2] = "SQUARE";
      for (int i = 0; i < tempString.length; i++) {
        capStyleCBM.addElement(tempString[i]);
      }
    }
    {
      String[] tempString = new String[3];
      tempString[0] = "MITER";
      tempString[1] = "ROUND";
      tempString[2] = "BEVEL";
      for (int i = 0; i < tempString.length; i++) {
        miterStyleCBM.addElement(tempString[i]);
      }
    }
    getContentPane().setLayout(new BorderLayout(0, 0));
    setSize(500, 490);
    setVisible(false);
    buttonPanel.setBorder(etchedBorder1);
    buttonPanel.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5));
    vectorMaxSizeTextField.setColumns(8);
    vectorScaleTextField.setColumns(8);
    JLabel5.setText("Style:");
    colorPanel.setBorder(etchedBorder1);
    colorPanel.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5));
    JLabel1.setText("Color:");
    offsetAngleTextField.setColumns(8);
    vectorStyleComboBox.setModel(vectorStyleCBM);
    vectorStyleComboBox.addActionListener(
        new VectorAttributeDialog_vectorStyleComboBox_actionAdapter(this));
    jLabel7.setText("Offset Angle:");
    jLabel6.setText("Max Size:");
    jLabel5.setText("Scale:");
    vectorPanel.setLayout(gridBagLayout2);
    jLabel11.setText("Fixed Size:");
    jLabel10.setText("Max Size:");
    headMinSizeTextField.setColumns(8);
    jLabel9.setText("Min Size:");
    jLabel8.setText("Scale:");
    headScaleTextField.setColumns(8);
    headMaxSizeTextField.setColumns(8);
    headFixedSizeTextField.setColumns(8);
    headPanel.setLayout(gridBagLayout4);
    markHeightTextField.setColumns(8);
    originStyleComboBox.setModel(originStyleCBM);
    JLabel12.setText("Color:");
    JLabel7.setText("Mark Height:");
    JLabel6.setText("Mark:");
    markPanel.setLayout(new GridBagLayout());
    markEditor.addActionListener(new VectorAttributeDialog_markEditor_actionAdapter(this));
    markEditor.setActionCommand("...");
    //    markEditor.setMargin(new Insets(0, 0, 0, 0));
    markColorPanel.setBorder(etchedBorder1);
    Mark.setLayout(gridBagLayout3);
    jLabel4.setText("Style:");
    plotMarkIconLabel.setForeground(java.awt.Color.black);
    plotMarkIconLabel.setIcon(pmIcon_);
    miterLimitTextField.setColumns(8);
    JLabel10.setText(" Width:");
    strokePanel.setLayout(gridBagLayout1);
    miterStyleComboBox.setModel(miterStyleCBM);
    jLabel3.setText("Miter Limit:");
    jLabel2.setText("Miter Style:");
    jLabel1.setText("Cap Style:");
    capStyleComboBox.setModel(capStyleCBM);
    widthTextField.setColumns(8);
    getContentPane().add(buttonPanel, "South");
    buttonPanel.setBounds(0, 263, 430, 39);
    okButton.setText("OK");
    okButton.setActionCommand("OK");
    buttonPanel.add(okButton);
    okButton.setBounds(115, 7, 51, 25);
    applyButton.setText("Apply");
    applyButton.setActionCommand("Apply");
    buttonPanel.add(applyButton);
    applyButton.setBounds(171, 7, 65, 25);
    cancelButton.setText("Cancel");
    cancelButton.setActionCommand("Cancel");
    buttonPanel.add(cancelButton);
    cancelButton.setBounds(241, 7, 73, 25);
    // $$ etchedBorder1.move(0,300);
    this.getContentPane().add(jTabbedPane1, BorderLayout.CENTER);
    jTabbedPane1.add(vectorPanel, "Vector");
    vectorPanel.add(
        vectorStyleComboBox,
        new GridBagConstraints(
            1,
            0,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(15, 5, 5, 5),
            0,
            0));
    vectorPanel.add(
        colorPanel,
        new GridBagConstraints(
            1,
            1,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(5, 5, 5, 15),
            0,
            0));
    vectorPanel.add(
        JLabel1,
        new GridBagConstraints(
            0,
            1,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.EAST,
            GridBagConstraints.NONE,
            new Insets(0, 5, 0, 5),
            0,
            0));
    vectorPanel.add(
        jLabel5,
        new GridBagConstraints(
            0,
            2,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.EAST,
            GridBagConstraints.NONE,
            new Insets(0, 6, 0, 6),
            0,
            0));
    vectorPanel.add(
        jLabel6,
        new GridBagConstraints(
            0,
            3,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.EAST,
            GridBagConstraints.NONE,
            new Insets(0, 5, 0, 5),
            0,
            0));
    vectorPanel.add(
        jLabel7,
        new GridBagConstraints(
            0,
            4,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.EAST,
            GridBagConstraints.NONE,
            new Insets(0, 15, 10, 5),
            0,
            0));
    vectorPanel.add(
        vectorScaleTextField,
        new GridBagConstraints(
            1,
            2,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(5, 5, 5, 5),
            0,
            0));
    vectorPanel.add(
        vectorMaxSizeTextField,
        new GridBagConstraints(
            1,
            3,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(5, 5, 5, 5),
            0,
            0));
    vectorPanel.add(
        offsetAngleTextField,
        new GridBagConstraints(
            1,
            4,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(5, 5, 15, 5),
            0,
            0));
    vectorPanel.add(
        JLabel5,
        new GridBagConstraints(
            0,
            0,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.EAST,
            GridBagConstraints.NONE,
            new Insets(10, 5, 0, 5),
            0,
            0));
    jTabbedPane1.add(headPanel, "Head");
    headPanel.add(
        jLabel8,
        new GridBagConstraints(
            0,
            0,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.EAST,
            GridBagConstraints.NONE,
            new Insets(0, 5, 0, 5),
            0,
            0));
    headPanel.add(
        headScaleTextField,
        new GridBagConstraints(
            1,
            0,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(5, 5, 5, 5),
            0,
            0));
    headPanel.add(
        jLabel9,
        new GridBagConstraints(
            0,
            1,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.EAST,
            GridBagConstraints.NONE,
            new Insets(0, 5, 0, 5),
            0,
            0));
    headPanel.add(
        jLabel10,
        new GridBagConstraints(
            0,
            2,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.EAST,
            GridBagConstraints.NONE,
            new Insets(0, 5, 0, 5),
            0,
            0));
    headPanel.add(
        headMinSizeTextField,
        new GridBagConstraints(
            1,
            1,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(5, 5, 5, 5),
            0,
            0));
    headPanel.add(
        headMaxSizeTextField,
        new GridBagConstraints(
            1,
            2,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(5, 5, 5, 5),
            0,
            0));
    headPanel.add(
        jLabel11,
        new GridBagConstraints(
            0,
            3,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.EAST,
            GridBagConstraints.NONE,
            new Insets(0, 5, 0, 5),
            0,
            0));
    headPanel.add(
        headFixedSizeTextField,
        new GridBagConstraints(
            1,
            3,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(5, 5, 5, 5),
            0,
            0));
    jTabbedPane1.add(Mark, "Mark");
    Mark.add(
        markPanel,
        new GridBagConstraints(
            1,
            2,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(5, 5, 5, 5),
            0,
            0));
    markPanel.add(
        plotMarkIconLabel,
        new GridBagConstraints(
            0,
            0,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.NONE,
            new Insets(0, 0, 0, 5),
            0,
            0));
    markPanel.add(
        markEditor,
        new GridBagConstraints(
            2,
            0,
            1,
            1,
            0.0,
            1.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.VERTICAL,
            new Insets(0, 0, 0, 0),
            0,
            0));
    Mark.add(
        JLabel6,
        new GridBagConstraints(
            0,
            2,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.EAST,
            GridBagConstraints.NONE,
            new Insets(0, 5, 0, 5),
            0,
            0));
    Mark.add(
        JLabel7,
        new GridBagConstraints(
            0,
            3,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.EAST,
            GridBagConstraints.NONE,
            new Insets(0, 15, 10, 5),
            0,
            0));
    Mark.add(
        markHeightTextField,
        new GridBagConstraints(
            1,
            3,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(5, 5, 15, 5),
            0,
            0));
    Mark.add(
        markColorPanel,
        new GridBagConstraints(
            1,
            1,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(5, 5, 5, 15),
            0,
            0));
    Mark.add(
        JLabel12,
        new GridBagConstraints(
            0,
            1,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.EAST,
            GridBagConstraints.NONE,
            new Insets(0, 5, 0, 5),
            0,
            0));
    Mark.add(
        jLabel4,
        new GridBagConstraints(
            0,
            0,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.EAST,
            GridBagConstraints.NONE,
            new Insets(10, 5, 0, 5),
            0,
            0));
    Mark.add(
        originStyleComboBox,
        new GridBagConstraints(
            1,
            0,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(15, 5, 5, 5),
            0,
            0));
    jTabbedPane1.add(strokePanel, "Line Style");
    strokePanel.add(
        JLabel10,
        new GridBagConstraints(
            0,
            0,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.EAST,
            GridBagConstraints.NONE,
            new Insets(0, 5, 0, 5),
            0,
            0));
    strokePanel.add(
        widthTextField,
        new GridBagConstraints(
            1,
            0,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(0, 5, 5, 5),
            0,
            0));
    strokePanel.add(
        jLabel1,
        new GridBagConstraints(
            0,
            2,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.EAST,
            GridBagConstraints.NONE,
            new Insets(0, 5, 0, 5),
            0,
            0));
    strokePanel.add(
        jLabel2,
        new GridBagConstraints(
            0,
            3,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.EAST,
            GridBagConstraints.NONE,
            new Insets(0, 5, 0, 5),
            0,
            0));
    strokePanel.add(
        capStyleComboBox,
        new GridBagConstraints(
            1,
            2,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(0, 5, 5, 5),
            0,
            0));
    strokePanel.add(
        miterStyleComboBox,
        new GridBagConstraints(
            1,
            3,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(0, 5, 5, 5),
            0,
            0));
    strokePanel.add(
        jLabel3,
        new GridBagConstraints(
            0,
            4,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.EAST,
            GridBagConstraints.NONE,
            new Insets(0, 5, 0, 5),
            0,
            0));
    strokePanel.add(
        miterLimitTextField,
        new GridBagConstraints(
            1,
            4,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(0, 5, 5, 5),
            0,
            0));
    // $$ stringComboBoxModel1.move(24,300);
    setTitle("VectorAttribute Properties");

    SymWindow aSymWindow = new SymWindow();
    this.addWindowListener(aSymWindow);
    SymAction lSymAction = new SymAction();
    cancelButton.addActionListener(lSymAction);
    okButton.addActionListener(lSymAction);
    applyButton.addActionListener(lSymAction);
  }