// Modified for Intergeo File Format (Yves Kreis) --> // private void writeThumbnail(Construction cons, ZipOutputStream zip) // throws IOException { private void writeThumbnail(Construction cons, ZipOutputStream zip, String fileName) throws IOException { // <-- Modified for Intergeo File Format (Yves Kreis) EuclidianView ev = app.getEuclidianView(); // max 128 pixels either way /* double exportScale = Math.min(THUMBNAIL_PIXELS_X / ev.getSelectedWidth(), THUMBNAIL_PIXELS_X / ev.getSelectedHeight()); */ try { // BufferedImage img = app.getExportImage(exportScale); BufferedImage img = app.getExportImage(THUMBNAIL_PIXELS_X, THUMBNAIL_PIXELS_Y); if (img != null) // Modified for Intergeo File Format (Yves Kreis) --> // writeImageToZip(zip, XML_FILE_THUMBNAIL, img); writeImageToZip(zip, fileName, img); // <-- Modified for Intergeo File Format (Yves Kreis) } catch (Exception e) { } // catch error if size is zero }
private void doActionPerformed(Object source) { if (source == btBackgroundColor) { view.setBackground(app.getGuiManager().showColorChooser(view.getBackground())); } else if (source == btAxesColor) { view.setAxesColor(app.getGuiManager().showColorChooser(view.getAxesColor())); } else if (source == btGridColor) { view.setGridColor(app.getGuiManager().showColorChooser(view.getGridColor())); } else if (source == cbShowAxes) { // view.showAxes(cbShowAxes.isSelected(), cbShowAxes.isSelected()); view.setShowAxes(cbShowAxes.isSelected(), true); } else if (source == cbShowGrid) { view.showGrid(cbShowGrid.isSelected()); } else if (source == cbBoldGrid) { view.setGridIsBold(cbBoldGrid.isSelected()); // Michael Borcherds 2008-04-11 } else if (source == cbShowMouseCoords) { view.setAllowShowMouseCoords(cbShowMouseCoords.isSelected()); } else if (source == cbGridType) { view.setGridType(cbGridType.getSelectedIndex()); } else if (source == cbAxesStyle) { view.setAxesLineStyle(cbAxesStyle.getSelectedIndex()); } else if (source == cbGridStyle) { int type = ((Integer) cbGridStyle.getSelectedItem()).intValue(); view.setGridLineStyle(type); } else if (source == cbGridManualTick) { view.setAutomaticGridDistance(!cbGridManualTick.isSelected()); } else if (source == tfAxesRatioX || source == tfAxesRatioY) { double xval = parseDouble(tfAxesRatioX.getText()); double yval = parseDouble(tfAxesRatioY.getText()); if (!(Double.isInfinite(xval) || Double.isNaN(xval) || Double.isInfinite(yval) || Double.isNaN(yval))) { // ratio = xval / yval // xscale / yscale = ratio // => yscale = xscale * xval/yval view.setCoordSystem( view.getXZero(), view.getYZero(), view.getXscale(), view.getXscale() * xval / yval); } } else if (source == cbView) { if (cbView.getSelectedIndex() == 0) setView(app.getEuclidianView()); else setView(app.getGuiManager().getEuclidianView2()); } else if (source == tfMinX) { double min = kernel.getAlgebraProcessor().evaluateToDouble(tfMinX.getText()); double max = view.getXmax(); if (min + Kernel.MIN_PRECISION < max) { view.setRealWorldCoordSystem(min, max, view.getYmin(), view.getYmax()); } } else if (source == tfMaxX) { double min = view.getXmin(); double max = kernel.getAlgebraProcessor().evaluateToDouble(tfMaxX.getText()); if (min + Kernel.MIN_PRECISION < max) { view.setRealWorldCoordSystem(min, max, view.getYmin(), view.getYmax()); } } else if (source == tfMinY) { double min = kernel.getAlgebraProcessor().evaluateToDouble(tfMinY.getText()); double max = view.getYmax(); if (min + Kernel.MIN_PRECISION < max) { view.setRealWorldCoordSystem(view.getXmin(), view.getXmax(), min, max); } } else if (source == tfMaxY) { double min = view.getYmin(); double max = kernel.getAlgebraProcessor().evaluateToDouble(tfMaxY.getText()); if (min + Kernel.MIN_PRECISION < max) { view.setRealWorldCoordSystem(view.getXmin(), view.getXmax(), min, max); } } view.updateBackground(); updateGUI(); }
/** * Sets default color for given geo. Note: this is mostly kept for downward compatibility. * * @param geo The element which needs new default visual styles * @param isReset If the visual styles should be reset */ public final void setDefaultVisualStyles(GeoElement geo, boolean isReset) { // all object types that are not specifically supported // should get the default values of a line // int type = DEFAULT_LINE; int type = getDefaultType(geo); // default GeoElement defaultGeo = getDefaultGeo(type); Application app = cons.getApplication(); if (defaultGeo != null) { geo.setAllVisualProperties(defaultGeo, isReset); if (geo instanceof GeoFunction) geo.setAlphaValue(defaultGeo.getAlphaValue()); if (!isReset) { // set to highest used layer if (app != null) { EuclidianView ev = app.getEuclidianView(); if (ev != null) geo.setLayer(ev.getMaxLayerUsed()); } } } // label visibility int labelingStyle = app == null ? LABEL_VISIBLE_USE_DEFAULTS : app.getLabelingStyle(); // automatic labelling: // if algebra window open -> all labels // else -> no labels if (labelingStyle == LABEL_VISIBLE_AUTOMATIC) { if (app.hasFullGui()) { labelingStyle = LABEL_VISIBLE_USE_DEFAULTS; /* TODO method chains doesn't allow app.getGuiManager().showAlgebraView() to appear here, fix this (F.S.) labelingStyle = app.getGuiManager().showAlgebraView() ? LABEL_VISIBLE_USE_DEFAULTS : LABEL_VISIBLE_ALWAYS_OFF;*/ } else { labelingStyle = LABEL_VISIBLE_USE_DEFAULTS; } } switch (labelingStyle) { case LABEL_VISIBLE_ALWAYS_ON: geo.setLabelVisible(true); break; case LABEL_VISIBLE_ALWAYS_OFF: geo.setLabelVisible(false); break; case LABEL_VISIBLE_POINTS_ONLY: geo.setLabelVisible(geo.isGeoPoint()); break; default: case LABEL_VISIBLE_USE_DEFAULTS: // don't change anything break; } if (blackWhiteMode) { // use black color and no filling geo.setObjColor(Color.black); geo.setAlphaValue(0f); } /* void initSetLabelVisible() { labelVisible = ! isPath() || app.showAlgebraView(); }*/ }
public void updateGUI() { btBackgroundColor.setForeground(view.getBackground()); btAxesColor.setForeground(view.getAxesColor()); btGridColor.setForeground(view.getGridColor()); cbShowAxes.removeActionListener(this); cbShowAxes.setSelected(view.getShowXaxis() && view.getShowYaxis()); cbShowAxes.addActionListener(this); cbShowGrid.removeActionListener(this); cbShowGrid.setSelected(view.getShowGrid()); cbShowGrid.addActionListener(this); // Michael Borcherds 2008-04-11 cbBoldGrid.removeActionListener(this); cbBoldGrid.setSelected(view.getGridIsBold()); cbBoldGrid.addActionListener(this); cbShowMouseCoords.removeActionListener(this); cbShowMouseCoords.setSelected(view.getAllowShowMouseCoords()); cbShowMouseCoords.addActionListener(this); cbView.removeActionListener(this); if (view == app.getEuclidianView()) cbView.setSelectedIndex(0); else cbView.setSelectedIndex(1); cbView.addActionListener(this); tfMinX.removeActionListener(this); tfMaxX.removeActionListener(this); tfMinY.removeActionListener(this); tfMaxY.removeActionListener(this); tfMinX.setText(kernel.format(view.getXmin())); tfMaxX.setText(kernel.format(view.getXmax())); tfMinY.setText(kernel.format(view.getYmin())); tfMaxY.setText(kernel.format(view.getYmax())); tfMinX.addActionListener(this); tfMaxX.addActionListener(this); tfMinY.addActionListener(this); tfMaxY.addActionListener(this); cbGridType.removeActionListener(this); cbGridType.setSelectedIndex(view.getGridType()); cbGridType.addActionListener(this); cbAxesStyle.removeActionListener(this); cbAxesStyle.setSelectedIndex(view.getAxesLineStyle()); cbAxesStyle.addActionListener(this); cbGridStyle.removeActionListener(this); int type = view.getGridLineStyle(); for (int i = 0; i < cbGridStyle.getItemCount(); i++) { if (type == ((Integer) cbGridStyle.getItemAt(i)).intValue()) { cbGridStyle.setSelectedIndex(i); break; } } cbGridStyle.addActionListener(this); cbGridManualTick.removeActionListener(this); boolean autoGrid = view.isAutomaticGridDistance(); cbGridManualTick.setSelected(!autoGrid); cbGridManualTick.addActionListener(this); ncbGridTickX.removeItemListener(this); ncbGridTickY.removeItemListener(this); cbGridTickAngle.removeItemListener(this); double[] gridTicks = view.getGridDistances(); if (view.getGridType() != EuclidianView.GRID_POLAR) { ncbGridTickY.setVisible(true); gridLabel2.setVisible(true); cbGridTickAngle.setVisible(false); gridLabel3.setVisible(false); ncbGridTickX.setValue(gridTicks[0]); ncbGridTickY.setValue(gridTicks[1]); gridLabel1.setText("x:"); } else { ncbGridTickY.setVisible(false); gridLabel2.setVisible(false); cbGridTickAngle.setVisible(true); gridLabel3.setVisible(true); ncbGridTickX.setValue(gridTicks[0]); int val = (int) (view.getGridDistances(2) * 12 / Math.PI) - 1; if (val == 5) val = 4; // handle Pi/2 problem cbGridTickAngle.setSelectedIndex(val); gridLabel1.setText("r:"); } ncbGridTickX.setEnabled(!autoGrid); ncbGridTickY.setEnabled(!autoGrid); cbGridTickAngle.setEnabled(!autoGrid); ncbGridTickX.addItemListener(this); ncbGridTickY.addItemListener(this); cbGridTickAngle.addItemListener(this); tfAxesRatioX.removeActionListener(this); tfAxesRatioY.removeActionListener(this); double xscale = view.getXscale(); double yscale = view.getYscale(); if (xscale >= yscale) { tfAxesRatioX.setText("1"); tfAxesRatioY.setText(nfAxesRatio.format(xscale / yscale)); } else { tfAxesRatioX.setText(nfAxesRatio.format(yscale / xscale)); tfAxesRatioY.setText("1"); } tfAxesRatioX.addActionListener(this); tfAxesRatioY.addActionListener(this); xAxisPanel.updatePanel(); yAxisPanel.updatePanel(); }
/** Initialize the GUI. */ private void initGUI() { setLayout(new BorderLayout()); // init tabs defaultsPanel = new OptionsDefaults(app); euclidianPanel = new OptionsEuclidian(app, app.getEuclidianView()); spreadsheetPanel = new OptionsSpreadsheet(app, (SpreadsheetView) app.getGuiManager().getSpreadsheetView()); casPanel = new OptionsCAS(app); advancedPanel = new OptionsAdvanced(app); // init scroll panes for tabs (show no extra borders) JScrollPane euclidianPanelScroll = new JScrollPane(euclidianPanel); euclidianPanelScroll.setBorder(BorderFactory.createEmptyBorder()); // init tabbing pane tabbedPane = new OptionsTabbedPane(); // defaults tabbedPane.addTab("", app.getToolBarImage("mode_delete_32.gif", Color.RED), defaultsPanel); // euclidian properties tabbedPane.addTab( "", app.getToolBarImage("mode_delete_32.gif", Color.RED), euclidianPanelScroll); // spreadsheet properties tabbedPane.addTab("", app.getToolBarImage("mode_delete_32.gif", Color.RED), spreadsheetPanel); // CAS properties tabbedPane.addTab("", app.getToolBarImage("mode_delete_32.gif", Color.RED), casPanel); // advanced tabbedPane.addTab("", app.getToolBarImage("mode_delete_32.gif", Color.RED), advancedPanel); // disable some tabs for applets if (app.isApplet()) { tabbedPane.setEnabledAt(TAB_DEFAULTS, false); } add(tabbedPane, BorderLayout.CENTER); // init close button JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); buttonPanel.setBorder(BorderFactory.createMatteBorder(1, 0, 0, 0, SystemColor.controlDkShadow)); buttonPanel.setBackground(Color.white); saveButton = new JButton(); saveButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { GeoGebraPreferences.getPref().saveXMLPreferences(app); } }); buttonPanel.add(saveButton); closeButton = new JButton(); closeButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { closeDialog(); } }); buttonPanel.add(closeButton); add(buttonPanel, BorderLayout.SOUTH); setLabels(); // update all labels setPreferredSize(new Dimension(640, 480)); pack(); setLocationRelativeTo(null); }