public JPanel update(Object[] geos) { this.geos = geos; if (!checkGeos(geos)) return null; tfAnimStep.removeActionListener(this); // check if properties have same values GeoElement temp, geo0 = (GeoElement) geos[0]; boolean equalStep = true; boolean onlyAngles = true; for (int i = 0; i < geos.length; i++) { temp = (GeoElement) geos[i]; // same object visible value if (!Kernel.isEqual(geo0.getAnimationStep(), temp.getAnimationStep())) equalStep = false; if (!(temp.isGeoAngle())) onlyAngles = false; } // set trace visible checkbox // int oldDigits = kernel.getMaximumFractionDigits(); // kernel.setMaximumFractionDigits(PropertiesDialog.TEXT_FIELD_FRACTION_DIGITS); StringTemplate highPrecision = StringTemplate.printDecimals( StringType.GEOGEBRA, PropertiesDialog.TEXT_FIELD_FRACTION_DIGITS, false); if (equalStep) { GeoElement stepGeo = geo0.getAnimationStepObject(); if (onlyAngles && (stepGeo == null || (!stepGeo.isLabelSet() && stepGeo.isIndependent()))) tfAnimStep.setText(kernel.formatAngle(geo0.getAnimationStep(), highPrecision).toString()); else tfAnimStep.setText(stepGeo.getLabel(highPrecision)); } else tfAnimStep.setText(""); tfAnimStep.addActionListener(this); return this; }
private void doActionPerformed() { NumberValue newVal = kernel.getAlgebraProcessor().evaluateToNumeric(tfAnimStep.getText(), true); if (newVal != null && !Double.isNaN(newVal.getDouble())) { for (int i = 0; i < geos.length; i++) { GeoElement geo = (GeoElement) geos[i]; geo.setAnimationStep(newVal); geo.updateRepaint(); } } update(geos); }
public AnimationStepPanel(AppD app) { kernel = app.getKernel(); // text field for animation step label = new JLabel(); tfAnimStep = new AngleTextField(6, app); label.setLabelFor(tfAnimStep); tfAnimStep.addActionListener(this); tfAnimStep.addFocusListener(this); // put it all together JPanel animPanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); animPanel.add(label); animPanel.add(tfAnimStep); setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); animPanel.setAlignmentX(Component.LEFT_ALIGNMENT); add(animPanel); setLabels(); }
public void updateFonts() { Font font = ((AppD) kernel.getApplication()).getPlainFont(); label.setFont(font); tfAnimStep.setFont(font); }