コード例 #1
0
  /** put all the needed things in the blackboards */
  private void commitToBlackboards(
      JGrassRegion jgR, CoordinateReferenceSystem crs, String windPath) {
    blackboard = getLayer().getMap().getBlackboard();

    style.north = (float) jgR.getNorth();
    style.south = (float) jgR.getSouth();
    style.east = (float) jgR.getEast();
    style.west = (float) jgR.getWest();
    style.rows = jgR.getRows();
    style.cols = jgR.getCols();

    style.windPath = windPath;

    try {

      try {
        Integer epsg = CRS.lookupEpsgCode(crs, true);
        style.crsString = "EPSG:" + epsg;
      } catch (Exception e) {
        // try non epsg
        style.crsString = CRS.lookupIdentifier(crs, true);
      }
    } catch (FactoryException e) {
      e.printStackTrace();
    }

    blackboard.put(ActiveregionStyleContent.ID, style);
    getLayer().setStatus(ILayer.DONE);
  }
コード例 #2
0
  @Override
  protected void refresh() {
    try {
      IBlackboard blackboard = getLayer().getMap().getBlackboard();

      style = (ActiveRegionStyle) blackboard.get(ActiveregionStyleContent.ID);

      if (style == null) {
        style = ActiveregionStyleContent.createDefault();
        blackboard.put(ActiveregionStyleContent.ID, style);
        // ((StyleBlackboard) styleBlackboard).setSelected(new
        // String[]{ActiveregionStyleContent.ID});
      }

      // first time choose the mapset
      if (style.windPath == null) {
        CatalogJGrassMapsetTreeViewerDialog mapsetDialog =
            new CatalogJGrassMapsetTreeViewerDialog();
        mapsetDialog.open(parent.getShell());
        jGrassMapsetGeoResource = mapsetDialog.getSelectedLayers().get(0);

        JGrassRegion activeRegionWindow = jGrassMapsetGeoResource.getActiveRegionWindow();
        style.windPath = jGrassMapsetGeoResource.getActiveRegionWindowPath();
        style.north = (float) activeRegionWindow.getNorth();
        style.south = (float) activeRegionWindow.getSouth();
        style.west = (float) activeRegionWindow.getWest();
        style.east = (float) activeRegionWindow.getEast();
        style.rows = activeRegionWindow.getRows();
        style.cols = activeRegionWindow.getCols();

        CoordinateReferenceSystem jGrassCrs = jGrassMapsetGeoResource.getLocationCrs();
        try {
          Integer epsg = CRS.lookupEpsgCode(jGrassCrs, true);
          style.crsString = "EPSG:" + epsg;
        } catch (Exception e) {
          // try non epsg
          style.crsString = CRS.lookupIdentifier(jGrassCrs, true);
        }
      }
      windPathText.setText(style.windPath);

      JGrassRegion tmp =
          new JGrassRegion(
              style.west, style.east, style.south, style.north, style.rows, style.cols);
      // set initial values
      isWorking = true;
      northText.setText(String.valueOf(style.north));
      southText.setText(String.valueOf(style.south));
      westText.setText(String.valueOf(style.west));
      eastText.setText(String.valueOf(style.east));
      xresText.setText(String.valueOf(tmp.getWEResolution()));
      yresText.setText(String.valueOf(tmp.getNSResolution()));
      colsText.setText(String.valueOf(style.cols));
      rowsText.setText(String.valueOf(style.rows));
      isWorking = false;

      forgroundAlphaText.setText(Float.toString(style.fAlpha));
      backgroundAlphaText.setText(Float.toString(style.bAlpha));
      foregroundColor.setColorValue(
          new RGB(
              style.foregroundColor.getRed(),
              style.foregroundColor.getGreen(),
              style.foregroundColor.getBlue()));
      backgroundColour.setColorValue(
          new RGB(
              style.backgroundColor.getRed(),
              style.backgroundColor.getGreen(),
              style.backgroundColor.getBlue()));

      CoordinateReferenceSystem crs = CRS.decode(style.crsString);
      commitToBlackboards(tmp, crs, style.windPath);
    } catch (Exception e) {
      e.printStackTrace();
    }
  }