/** Init the SIF ui factory */ private void initSIF() { UIFactory.setDefaultImageIcon(OrbisGISIcon.getIcon("orbisgis")); // Load SIF properties try { UIFactory.loadState(new File(viewWorkspace.getSIFPath())); } catch (IOException ex) { LOGGER.error(I18N.tr("Error while loading dialogs informations."), ex); } }
/** Opens a OK - Cancel window used to edit the symbol configuration, size excepted. */ public void onClickOnPreview(MouseEvent mouseEvent) { // We create a copy of the constant part of the symbol PointParameters pp = new PointParameters( proportionalPoint.getPenStroke().getLineColor(), proportionalPoint.getPenStroke().getLineOpacity(), proportionalPoint.getPenStroke().getLineWidth(), proportionalPoint.getPenStroke().getDashArray(), proportionalPoint.getFillLegend().getColor(), proportionalPoint.getFillLegend().getOpacity(), 3.0, 3.0, proportionalPoint.getWellKnownName()); UniqueSymbolPoint usp = new UniqueSymbolPoint(pp); if (proportionalPoint.getPenStroke() instanceof NullPenStrokeLegend) { usp.setPenStroke(new NullPenStrokeLegend()); } if (proportionalPoint.getFillLegend() instanceof NullSolidFillLegend) { usp.setFillLegend(new NullSolidFillLegend()); } usp.setStrokeUom(proportionalPoint.getStrokeUom()); usp.setSymbolUom(proportionalPoint.getSymbolUom()); ConfigPanel cp = new ConfigPanel(usp); if (UIFactory.showDialog(cp)) { affectValues(usp); getPreview().imageChanged(); } }
public void execute(final MapContext viewContext, final ILayer layer) { try { RasterLegend legend = (RasterLegend) layer.getRasterLegend()[0]; final RasterDefaultStyleUIPanel rasterDefaultStyleUIClass = new RasterDefaultStyleUIPanel(legend, layer.getRaster().getDefaultColorModel()); if (UIFactory.showDialog(rasterDefaultStyleUIClass)) { ColorModel colorModel = rasterDefaultStyleUIClass.getColorModel(); float opacity = rasterDefaultStyleUIClass.getOpacity(); if (colorModel == null) { colorModel = legend.getColorModel(); } RasterLegend newLegend = new RasterLegend(colorModel, opacity); layer.setLegend(newLegend); } } catch (DriverException e) { Services.getErrorManager().error("Cannot get the legend", e); } catch (IOException e) { Services.getErrorManager().error("Cannot get the default style", e); Services.getErrorManager().error("Cannot get the default style", e); } }
@Override public String validateInput() { if (lst.getSelectedIndex() == -1) { return UIFactory.getI18n().tr("You must select a legend."); } return null; }
private void addRule() { // We must add it just after the currently selected Rule. // Let's find which one it is. If there is none, we add it at the // end of the list. MultiInputPanel mip = new MultiInputPanel(I18N.tr("Choose a name for your rule")); mip.addInput("RuleName", I18N.tr("Name of the Rule : "), new TextBoxType(10)); mip.addValidation( new MIPValidation() { @Override public String validate(MultiInputPanel mid) { String ruleName = mid.getInput("RuleName"); return ruleName.isEmpty() ? I18N.tr("Rule name cannot be null or empty.") : null; } }); if (UIFactory.showDialog(mip)) { String s = mip.getInput("RuleName"); LegendTreeModel tm = (LegendTreeModel) tree.getModel(); // We need to link our new RuleWrapper with the layer we are editing. Rule temp = new Rule(simpleStyleEditor.getStyleWrapper().getStyle().getLayer()); temp.setName(s); Legend leg = LegendFactory.getLegend(temp.getCompositeSymbolizer().getSymbolizerList().get(0)); // Initialize a panel for this legend. ILegendPanel ilp = ILegendPanelFactory.getILegendPanel(simpleStyleEditor, leg); List<ILegendPanel> list = new ArrayList<ILegendPanel>(); list.add(ilp); RuleWrapper nrw = new RuleWrapper(simpleStyleEditor, temp, list); tm.addElement(tm.getRoot(), nrw, getSelectedRule()); simpleStyleEditor.legendAdded(nrw.getPanel()); } }
private void saveSIFState() { // Load SIF properties try { UIFactory.saveState(new File(viewWorkspace.getSIFPath())); } catch (IOException ex) { LOGGER.error(I18N.tr("Error while saving dialogs informations."), ex); } }
@Override public void actionPerformed(ActionEvent e) { if (e.getActionCommand().equals(EDIT)) { RecodedLine rl = (RecodedLine) getMappedLegend(); LineParameters lp = rl.get(getCellEditorValue()); UniqueSymbolLine usl = new UniqueSymbolLine(lp); PnlUniqueLineSE pls = new PnlUniqueLineSE(usl, false); if (UIFactory.showDialog(new UIPanel[] {pls}, true, true)) { LineParameters edited = usl.getLineParameters(); rl.put((String) getCellEditorValue(), edited); fireEditingStopped(); } fireEditingCanceled(); } }
/** * Core constructor, init Model instances * * @param debugMode Show additional information for debugging purposes * @note Call startup() to init Swing */ public Core(CoreWorkspaceImpl coreWorkspace, boolean debugMode, LoadingFrame splashScreen) throws InvocationTargetException, InterruptedException { ProgressMonitor parentProgress = splashScreen.getProgressMonitor(); ProgressMonitor progressInfo = parentProgress.startTask(I18N.tr("Loading Workspace.."), 100); MainContext.initConsoleLogger(debugMode); // Declare empty main frame mainFrame = new MainFrame(); // Set the main frame position and size mainFrame.setSize(MAIN_VIEW_SIZE); // Try to set the frame at the center of the default screen try { GraphicsDevice device = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice(); Rectangle screenBounds = device.getDefaultConfiguration().getBounds(); mainFrame.setLocation( screenBounds.x + screenBounds.width / 2 - MAIN_VIEW_SIZE.width / 2, screenBounds.y + screenBounds.height / 2 - MAIN_VIEW_SIZE.height / 2); } catch (Throwable ex) { LOGGER.error(ex.getLocalizedMessage(), ex); } UIFactory.setMainFrame(mainFrame); initMainContext(debugMode, coreWorkspace, splashScreen); progressInfo.progressTo(10); this.viewWorkspace = new ViewWorkspace(this.mainContext.getCoreWorkspace()); Services.registerService( ViewWorkspace.class, I18N.tr("Contains view folders path"), viewWorkspace); progressInfo.setTaskName(I18N.tr("Register GUI Sql functions..")); addSQLFunctions(); progressInfo.progressTo(11); // Load plugin host progressInfo.setTaskName(I18N.tr("Load the plugin framework..")); startPluginHost(); progressInfo.progressTo(18); progressInfo.setTaskName(I18N.tr("Connecting to the database..")); // Init database try { mainContext.initDataBase( coreWorkspace.getDataBaseUser(), coreWorkspace.getDataBasePassword()); } catch (SQLException ex) { throw new RuntimeException(ex.getLocalizedMessage(), ex); } initSIF(); progressInfo.progressTo(20); }
/** * Add a legend to the tree, in the currently selected RuleWrapper, after the currently selected * Legend (if any in both case). A RuleWrapper will be added in the case there is none. */ private void addLegend() { LegendUIChooser legendPicker = new LegendUIChooser(simpleStyleEditor); if (UIFactory.showDialog(legendPicker)) { // Recover the panel that was selected when the user clicked OK. ILegendPanel ilp = legendPicker.getSelectedPanel(); // Get the currently selected RuleWrapper, or the last one in this // style if none is currently selected. RuleWrapper currentrw = getSelectedRule(); StyleWrapper sw = simpleStyleEditor.getStyleWrapper(); if (currentrw == null) { if (sw.getSize() == 0) { addRule(); } currentrw = sw.getRuleWrapper(sw.getSize() - 1); } // Set the Legend's name. Legend legend = ilp.getLegend(); legend .getSymbolizer() .setName(getUniqueName(legend.getLegendTypeName(), currentrw.getRule(), 0)); // Add the panel to the LegendTree. ((LegendTreeModel) tree.getModel()).addElement(currentrw, ilp, getSelectedLegend()); // Automatically select the newly added legend in the tree. TreePath selectionPath = tree.getSelectionPath(); TreePath parent; if (selectionPath.getLastPathComponent() instanceof RuleWrapper) { parent = selectionPath; } else { parent = selectionPath.getParentPath(); } tree.setSelectionPath(parent.pathByAddingChild(ilp)); // Notify the SimpleStyleEditor that a Legend has been added. simpleStyleEditor.legendAdded(ilp); } }
/** Free all resources allocated by this object */ public void dispose() { // Close all running jobs final AppContext appContext = AppContext.getAppContext(); ExecutorService executorService = (ExecutorService) appContext.get(SwingWorker.class); if (executorService != null) { executorService.shutdown(); } // Free UI resources if (editors != null) { editors.dispose(); } if (geoCatalog != null) { geoCatalog.dispose(); } if (mainFrame != null) { mainFrame.dispose(); } if (singleFrameTracker != null) { singleFrameTracker.close(); } if (editorFactoryTracker != null) { editorFactoryTracker.close(); } if (editorTracker != null) { editorTracker.close(); } if (toolBarTracker != null) { toolBarTracker.close(); } dockManager.dispose(); loggerCollection.dispose(); // Free libraries resources mainContext.dispose(); UIFactory.setMainFrame(null); }
// ************************* UIPanel *************************** @Override public URL getIconURL() { return UIFactory.getDefaultIcon(); }