/** * Creates a new DataFunctionPanel for a track, autoloading appropriate data functions. * * @param track the track */ protected FunctionPanel createFunctionPanel(TTrack track) { FunctionPanel panel = new DataFunctionPanel(track.getData(trackerPanel)); panel.setIcon(track.getIcon(21, 16, "point")); // $NON-NLS-1$ Class<?> type = track.getClass(); if (PointMass.class.isAssignableFrom(type)) panel.setDescription(PointMass.class.getName()); else if (Vector.class.isAssignableFrom(type)) panel.setDescription(Vector.class.getName()); else if (RGBRegion.class.isAssignableFrom(type)) panel.setDescription(RGBRegion.class.getName()); else if (LineProfile.class.isAssignableFrom(type)) panel.setDescription(LineProfile.class.getName()); else panel.setDescription(type.getName()); final ParamEditor paramEditor = panel.getParamEditor(); if (track instanceof PointMass) { final PointMass m = (PointMass) track; Parameter param = (Parameter) paramEditor.getObject("m"); // $NON-NLS-1$ if (param == null) { param = new Parameter("m", String.valueOf(m.getMass())); // $NON-NLS-1$ param.setDescription( TrackerRes.getString("ParticleModel.Parameter.Mass.Description")); // $NON-NLS-1$ paramEditor.addObject(param, false); } param.setNameEditable(false); // mass name not editable paramEditor.addPropertyChangeListener( new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent e) { if ("m".equals(e.getOldValue())) { // $NON-NLS-1$ Parameter param = (Parameter) paramEditor.getObject("m"); // $NON-NLS-1$ if (m.getMass() != param.getValue()) { m.setMass(param.getValue()); m.massField.setValue(m.getMass()); } } } }); m.addPropertyChangeListener( "mass", new PropertyChangeListener() { //$NON-NLS-1$ public void propertyChange(PropertyChangeEvent e) { Parameter param = (Parameter) paramEditor.getObject("m"); // $NON-NLS-1$ double newMass = (Double) e.getNewValue(); if (newMass != param.getValue()) { paramEditor.setExpression("m", String.valueOf(newMass), false); // $NON-NLS-1$ } } }); } return panel; }
@Override public void setFontLevel(int level) { if (autoloadButton == null) return; level = Math.max(0, level); Object[] toSize = new Object[] {loadButton, saveButton, autoloadButton}; FontSizer.setFonts(toSize, level); for (String name : panels.keySet()) { TTrack track = trackerPanel.getTrack(name); FunctionPanel panel = panels.get(name); if (track == null || panel == null) continue; // get new footprint icon, automatically resized to current level panel.setIcon(track.getIcon(21, 16, "point")); // $NON-NLS-1$ } super.setFontLevel(level); validate(); autoloadButton.revalidate(); }