Unnamed: 0
int64 0
2.05k
| func
stringlengths 27
124k
| target
bool 2
classes | project
stringlengths 39
117
|
---|---|---|---|
700 | public class PlotViewPolicy implements Policy {
private static boolean hasFeed(AbstractComponent component) {
return component.getCapability(FeedProvider.class) != null || (component.getCapability(Placeholder.class) != null);
}
@Override
public ExecutionResult execute(PolicyContext context) {
boolean result = true;
ViewInfo viewInfo = context.getProperty(PolicyContext.PropertyName.TARGET_VIEW_INFO.getName(), ViewInfo.class);
if (viewInfo.getViewClass().equals(PlotViewManifestation.class)) {
AbstractComponent targetComponent = context.getProperty(PolicyContext.PropertyName.TARGET_COMPONENT.getName(), AbstractComponent.class);
if (targetComponent.isLeaf() && !isALeafComponentThatRequiresAPlot(targetComponent)) {
String message = "Leaf is not a feed.";
return new ExecutionResult(context, false, message);
}
result = !rejectCanvasView(context,targetComponent);
}
String message;
if (result) {
message = "Requested Plot View has children with data feeds.";
} else {
message = "Requested Plot View did not have children with data feeds.";
}
return new ExecutionResult(context, result, message);
}
/**
* Only allow the plot view to be visible in a canvas view if the component is a leaf, this allow the plot view to be the default canvas
* for a FeedProvider. However, since the plot view is now also a canvas view always allow the canvas view role if the plot view role is
* asked for directly.
* @param context
* @param component
* @return
*/
private boolean rejectCanvasView(PolicyContext context, AbstractComponent component) {
return ViewType.CENTER.equals(context.getProperty(PolicyContext.PropertyName.VIEW_TYPE.getName())) &&
!component.isLeaf();
}
private final static AbstractComponent[][] COMPONENT_MATRIX_TYPE = new AbstractComponent[0][];
private final static AbstractComponent[] COMPONENT_VECTOR_TYPE = new AbstractComponent[0];
/**
* Gets the 2-dimensional matrix of components where the children are collections
* and the grand children are data feeds.
*
* @param targetComponent the parent component of the matrix
* @param ordinalPosition if the ordinal position in the list should determine the stacked plot
* @return a 2-dimensional array of components making up the matrix
*/
public static AbstractComponent[][] getPlotComponents(AbstractComponent targetComponent, boolean ordinalPosition) {
List<AbstractComponent[]> subPlots = new ArrayList<AbstractComponent[]>();
if (targetComponent!=null){
if (isALeafComponentThatRequiresAPlot(targetComponent)) {
// We need only add this component to the plot.
List<AbstractComponent> phantomChildren = new ArrayList<AbstractComponent>();
phantomChildren.add(targetComponent);
subPlots.add(phantomChildren.toArray(COMPONENT_VECTOR_TYPE));
} else if (isCompoundComponentWithAtLeastOneChildThatIsALeafAndThatRequiresAPlot(targetComponent)) {
List<AbstractComponent> children = new ArrayList<AbstractComponent>();
for (AbstractComponent component : targetComponent.getComponents()) {
if (isALeafComponentThatRequiresAPlot(component)) {
children.add(component);
}
}
subPlots.add(children.toArray(COMPONENT_VECTOR_TYPE));
} else if (isCompoundComponentWithCompoundChildrenThatRequirePlots(targetComponent)) {
List<List<AbstractComponent>> stackedPlots = new ArrayList<List<AbstractComponent>>();
if (ordinalPosition) {
// match based on ordinal position in the list
for (AbstractComponent component : targetComponent.getComponents()) {
if (!component.isLeaf() && !isEvaluator(component)) {
int childCount = 0;
for (AbstractComponent childComponent : component.getComponents()) {
if (hasFeed(childComponent)) {
if (stackedPlots.size() < ++childCount) {
stackedPlots.add(new ArrayList<AbstractComponent>());
}
stackedPlots.get(childCount-1).add(childComponent);
if (childCount == PlotConstants.MAX_NUMBER_SUBPLOTS) {
break;
}
}
}
}
}
} else {
int currentStackedPlots = 0;
for (AbstractComponent component : targetComponent.getComponents()) {
if (!component.isLeaf() && !isEvaluator(component)) {
if (++currentStackedPlots == PlotConstants.MAX_NUMBER_SUBPLOTS ) {
break;
}
List<AbstractComponent> feeds = new ArrayList<AbstractComponent>();
for (AbstractComponent childComponent : component.getComponents()) {
if (hasFeed(childComponent)) {
feeds.add(childComponent);
}
}
stackedPlots.add(feeds);
}
}
}
for (List<AbstractComponent> stackedPlot : stackedPlots) {
subPlots.add(stackedPlot.toArray(COMPONENT_VECTOR_TYPE));
}
}
}
return subPlots.toArray(COMPONENT_MATRIX_TYPE);
}
/**
* Returns true if component is a leaf component (cannot have children) and it has an associated data feed, false otherwise.
*
* @param component
* @return
*/
static boolean isALeafComponentThatRequiresAPlot(AbstractComponent component) {
return component.isLeaf() && hasFeed(component);
}
/**
* Returns true if the component is an evaluator component.
* @param component to determine whether it is an evaluator
* @return true if the component is an evaluator, false otherwise
*/
private static boolean isEvaluator(AbstractComponent component) {
return !component.isLeaf() && component.getCapability(Evaluator.class) != null;
}
/**
* Returns true if component is a compound component (has children) and at least one of those children
* isALeafComponentThatRequiresAPlot. False otherwise.
*
* @param component
* @return
*/
static boolean isCompoundComponentWithAtLeastOneChildThatIsALeafAndThatRequiresAPlot(AbstractComponent component) {
if (component.isLeaf()) {
return false;
}
for (AbstractComponent childComponent : component.getComponents()) {
if (isALeafComponentThatRequiresAPlot(childComponent)) {
return true;
}
}
return false;
}
/**
* Returns true if component is a compound component and all its children are compound components with
* at least one grand child component that isALeafComponentThatRequiresAPlot.
*
* @param component
* @return
*/
static boolean isCompoundComponentWithCompoundChildrenThatRequirePlots(AbstractComponent component) {
if (component.isLeaf() ||
isCompoundComponentWithAtLeastOneChildThatIsALeafAndThatRequiresAPlot(component)) {
return false;
}
// We no know that all children of component are not leafs that require a plot.
for (AbstractComponent childComponent : component.getComponents()) {
if (!childComponent.isLeaf() && isCompoundComponentWithAtLeastOneChildThatIsALeafAndThatRequiresAPlot(childComponent)) {
return true;
}
}
return false;
}
} | false | fastPlotViews_src_main_java_gov_nasa_arc_mct_fastplot_policy_PlotViewPolicy.java |
701 | public class TestPlotViewPolicy {
@Mock
private AbstractComponent leafWithAFeedComponent;
@Mock
private AbstractComponent leafWithOutAFeedComponent;
@Mock
private AbstractComponent nonLeafComponent;
@Mock
private AbstractComponent compoundComponent;
@Mock
private AbstractComponent childCompoundComponent1;
@Mock
private AbstractComponent childCompoundComponent2;
@Mock
private PolicyManager mockPolicyManager;
@Mock
private FeedProvider provider;
@BeforeMethod
public void setup() {
MockitoAnnotations.initMocks(this);
Mockito.when(leafWithAFeedComponent.isLeaf()).thenReturn(true);
Mockito.when(leafWithAFeedComponent.getCapability(FeedProvider.class)).thenReturn(provider);
Mockito.when(leafWithOutAFeedComponent.isLeaf()).thenReturn(true);
Mockito.when(leafWithOutAFeedComponent.getCapability(FeedProvider.class)).thenReturn(null);
Mockito.when(nonLeafComponent.isLeaf()).thenReturn(false);
Mockito.when(nonLeafComponent.getCapability(FeedProvider.class)).thenReturn(provider);
}
@Test
public void testIsALeafComponentThatRequiresAPlot() {
Assert.assertTrue(PlotViewPolicy.isALeafComponentThatRequiresAPlot(leafWithAFeedComponent));
Assert.assertFalse(PlotViewPolicy.isALeafComponentThatRequiresAPlot(leafWithOutAFeedComponent));
Assert.assertFalse(PlotViewPolicy.isALeafComponentThatRequiresAPlot(nonLeafComponent));
}
@Test
public void testIsCompoundComponentWithAtLeastOneChildThatIsALeafAndThatRequiresAPlot() {
Assert.assertFalse(PlotViewPolicy.isCompoundComponentWithAtLeastOneChildThatIsALeafAndThatRequiresAPlot(leafWithAFeedComponent));
Assert.assertFalse(PlotViewPolicy.isCompoundComponentWithAtLeastOneChildThatIsALeafAndThatRequiresAPlot(leafWithOutAFeedComponent));
// setup compound components with a child that requires a plot.
List<AbstractComponent> childComponents = new ArrayList<AbstractComponent>();
childComponents.add(leafWithAFeedComponent);
childComponents.add(leafWithOutAFeedComponent);
Mockito.when(compoundComponent.getComponents()).thenReturn(childComponents);
// we now have two children. One with a feed and one without.
Assert.assertTrue(PlotViewPolicy.isCompoundComponentWithAtLeastOneChildThatIsALeafAndThatRequiresAPlot(compoundComponent));
Assert.assertFalse(PlotViewPolicy.isCompoundComponentWithCompoundChildrenThatRequirePlots(compoundComponent));
// change our feed with a child to one without.
childComponents.remove(leafWithAFeedComponent);
Assert.assertFalse(PlotViewPolicy.isCompoundComponentWithAtLeastOneChildThatIsALeafAndThatRequiresAPlot(compoundComponent));
Assert.assertFalse(PlotViewPolicy.isCompoundComponentWithCompoundChildrenThatRequirePlots(compoundComponent));
}
@Test
public void testIsCompoundComponentWithCompoundChildrenThatRequirePlots() {
Assert.assertFalse(PlotViewPolicy.isCompoundComponentWithCompoundChildrenThatRequirePlots(leafWithAFeedComponent));
Assert.assertFalse(PlotViewPolicy.isCompoundComponentWithCompoundChildrenThatRequirePlots(leafWithOutAFeedComponent));
List<AbstractComponent> childComponents = new ArrayList<AbstractComponent>();
childComponents.add(childCompoundComponent1);
childComponents.add(childCompoundComponent2);
Mockito.when(compoundComponent.getComponents()).thenReturn(childComponents);
Mockito.when(compoundComponent.isLeaf()).thenReturn(false);
List<AbstractComponent> childCompound1Children = new ArrayList<AbstractComponent>();
List<AbstractComponent> childCompound2Children = new ArrayList<AbstractComponent>();
childCompound1Children.add(leafWithAFeedComponent);
childCompound2Children.add(leafWithOutAFeedComponent);
Mockito.when(childCompoundComponent1.getComponents()).thenReturn(childCompound1Children);
Mockito.when(childCompoundComponent2.getComponents()).thenReturn(childCompound2Children);
Mockito.when(childCompoundComponent1.isLeaf()).thenReturn(false);
Mockito.when(childCompoundComponent2.isLeaf()).thenReturn(false);
Assert.assertTrue(PlotViewPolicy.isCompoundComponentWithCompoundChildrenThatRequirePlots(compoundComponent));
Mockito.when(childCompoundComponent1.getComponents()).thenReturn(childCompound2Children);
Assert.assertFalse(PlotViewPolicy.isCompoundComponentWithCompoundChildrenThatRequirePlots(compoundComponent));
}
@Test
public void testGetNonCompoundPlotComponents() {
(new PolicyManagerAccess()).setPolicyManager(mockPolicyManager);
Mockito.when(mockPolicyManager.execute(Mockito.anyString(), Mockito.any(PolicyContext.class))).thenReturn(
new ExecutionResult(null,true,"test"));
AbstractComponent[][] components = PlotViewPolicy.getPlotComponents(leafWithAFeedComponent, true);
Assert.assertEquals(components.length,1);
Assert.assertSame(components[0][0], leafWithAFeedComponent);
components = PlotViewPolicy.getPlotComponents(leafWithOutAFeedComponent, true);
Assert.assertEquals(components.length,0);
// setup compound components with a child that requires a plot.
List<AbstractComponent> childComponents = new ArrayList<AbstractComponent>();
childComponents.add(leafWithAFeedComponent);
childComponents.add(leafWithOutAFeedComponent);
Mockito.when(compoundComponent.getComponents()).thenReturn(childComponents);
}
@Test
public void testGetCompoundPlotComponents() {
(new PolicyManagerAccess()).setPolicyManager(mockPolicyManager);
Mockito.when(mockPolicyManager.execute(Mockito.anyString(), Mockito.any(PolicyContext.class))).thenReturn(
new ExecutionResult(null,true,"test"));
// setup compound components with a child that requires a plot.
List<AbstractComponent> childComponents = new ArrayList<AbstractComponent>();
childComponents.add(leafWithAFeedComponent);
childComponents.add(leafWithOutAFeedComponent);
Mockito.when(compoundComponent.getComponents()).thenReturn(childComponents);
AbstractComponent[][] components = PlotViewPolicy.getPlotComponents(compoundComponent, true);
Assert.assertEquals(components.length,1);
Assert.assertSame(components[0][0], leafWithAFeedComponent);
}
private AbstractComponent createComponentWithNoFeed() {
AbstractComponent comp = Mockito.mock(AbstractComponent.class);
Mockito.when(comp.isLeaf()).thenReturn(true);
return comp;
}
private AbstractComponent createComponentWithFeed(String displayName) {
AbstractComponent comp = Mockito.mock(AbstractComponent.class);
Mockito.when(comp.isLeaf()).thenReturn(true);
Mockito.when(comp.getDisplayName()).thenReturn(displayName);
Mockito.when(comp.getCapability(FeedProvider.class)).thenReturn(provider);
return comp;
}
private AbstractComponent createComponentWithChildren(int numChildren, String prefix) {
AbstractComponent comp = Mockito.mock(AbstractComponent.class);
List<AbstractComponent> childComponents = new ArrayList<AbstractComponent>();
Mockito.when(comp.getComponents()).thenReturn(childComponents);
childComponents.add(createComponentWithNoFeed());
for (int i =0; i < numChildren; i++) {
childComponents.add(createComponentWithFeed(prefix+Integer.toString(i)));
}
return comp;
}
@Test
public void testRejectCanvasView() throws Exception {
(new PolicyManagerAccess()).setPolicyManager(mockPolicyManager);
AbstractComponent comp = Mockito.mock(AbstractComponent.class);
PlotViewPolicy policy = new PlotViewPolicy();
PolicyContext context = new PolicyContext();
context.setProperty(PolicyContext.PropertyName.TARGET_VIEW_INFO.getName(), new ViewInfo(PlotViewManifestation.class,"",ViewType.CENTER));
Method m = policy.getClass().getDeclaredMethod("rejectCanvasView", PolicyContext.class, AbstractComponent.class);
m.setAccessible(true);
Mockito.when(comp.isLeaf()).thenReturn(false);
Assert.assertEquals(m.invoke(policy, context, comp), Boolean.FALSE, "direct access to plot view role should always be true");
context.setProperty(PolicyContext.PropertyName.VIEW_TYPE.getName(), ViewType.CENTER);
Assert.assertEquals(m.invoke(policy, context, comp), Boolean.TRUE, "collections must not support canvas view roles");
Mockito.when(comp.isLeaf()).thenReturn(true);
Assert.assertEquals(m.invoke(policy, context, comp), Boolean.FALSE, "leafs must support canvas view roles");
}
@Test
public void testGetCompoundPlotComponentsWithChildren() {
(new PolicyManagerAccess()).setPolicyManager(mockPolicyManager);
Mockito.when(mockPolicyManager.execute(Mockito.anyString(), Mockito.any(PolicyContext.class))).thenReturn(
new ExecutionResult(null,true,"test"));
// setup compound components with a child that requires a plot.
List<AbstractComponent> childComponents = new ArrayList<AbstractComponent>();
String start = "A";
for (int i = 0; i < 12; i++) {
AbstractComponent child = createComponentWithChildren(12, start);
childComponents.add(child);
start+="'";
}
Mockito.when(compoundComponent.getComponents()).thenReturn(childComponents);
// also verify the sequence of components names to make sure the group is being divided equally
AbstractComponent[][] components = PlotViewPolicy.getPlotComponents(compoundComponent, true);
Assert.assertEquals(components.length,10);
int offset = 0;
for (AbstractComponent[] col:components) {
Assert.assertEquals(col.length,12);
String sequence = "A";
for (AbstractComponent component : col) {
Assert.assertEquals(component.getDisplayName(), sequence+Integer.valueOf(offset));
sequence+="'";
}
offset++;
}
}
} | false | fastPlotViews_src_test_java_gov_nasa_arc_mct_fastplot_policy_TestPlotViewPolicy.java |
702 | public class TestTruncatingLabel {
private int width = 10;
private static final String TEXT = "This is some text.";
@Test
public void testPaint() {
JLabel truncatingLabel = new TruncatingLabel();
JLabel plainLabel = new JLabel();
truncatingLabel.setText(TEXT);
plainLabel.setText(TEXT);
JPanel testPanel = new JPanel() {
public int getWidth() {
return width;
}
};
testPanel.add(truncatingLabel);
testPanel.add(plainLabel);
// We need a JFrame to make the panel do any layout
JFrame testFrame = new JFrame();
testFrame.getContentPane().add(testPanel);
testFrame.pack();
width = 1000; // Plenty of room, should draw the same
Assert.assertEquals(true, matches( draw(truncatingLabel), draw(plainLabel) ));
width = 20; // Very narrow, should truncate
Assert.assertEquals(false, matches( draw(truncatingLabel), draw(plainLabel) ));
}
private boolean matches (BufferedImage a, BufferedImage b) {
if (a.getWidth () != b.getWidth ()) throw new IllegalArgumentException("Images must have same dimensions");
if (a.getHeight() != b.getHeight()) throw new IllegalArgumentException("Images must have same dimensions");
for (int x = 0; x < a.getWidth(); x++) {
for (int y = 0; y < a.getHeight(); y++) {
if (a.getRGB(x, y) != b.getRGB(x, y)) return false;
}
}
return true;
}
private BufferedImage draw(JLabel label) {
BufferedImage image = new BufferedImage(label.getWidth(), label.getHeight(), BufferedImage.TYPE_INT_RGB);
Graphics g = image.getGraphics();
label.paint(g);
return image;
}
} | false | fastPlotViews_src_test_java_gov_nasa_arc_mct_fastplot_util_TestTruncatingLabel.java |
703 | JPanel testPanel = new JPanel() {
public int getWidth() {
return width;
}
}; | false | fastPlotViews_src_test_java_gov_nasa_arc_mct_fastplot_util_TestTruncatingLabel.java |
704 | public class AbbreviatingPlotLabelingAlgorithm {
private final static Logger logger = LoggerFactory.getLogger(AbbreviatingPlotLabelingAlgorithm.class);
public final static List<String> globalContextLabels = new ArrayList<String>();
private List<String> panelContextTitleList = new ArrayList<String>();
private List<String> canvasContextTitleList = new ArrayList<String>();
private String panelOrWindowTitle = "";
private String canvasPanelTitle = "";
private String name = "";
/**
* Creates a new instance of the labeling algorithm.
*/
public AbbreviatingPlotLabelingAlgorithm() { }
/**
* Computes a label for a row or column with a set of cell identifiers.
* The resulting label should have all words that are common among the
* cells, excluding any words that are in the surrounding context labels.
* Labels from the surrounding context could be from an existing
* row or column label or from a surrounding panel or window, for example.
*
* @param identifiers the cell identifiers for the row or column
* @param contextLabels the labels for the surrounding context
* @return the label for the row or column
*/
public String computeLabel(List<String> identifiers, List<String> contextLabels) {
List<String> labelWords = null;
for (int i=0; i < identifiers.size(); i++) {
List<String> cellLabelWords = StringUtils.split(identifiers.get(i), PlotConstants.WORD_DELIMITER_PATTERN);
if (cellLabelWords.size() > 0) {
if (labelWords == null) {
labelWords = cellLabelWords;
} else {
labelWords.retainAll(cellLabelWords);
}
}
}
if (labelWords == null) {
return "";
} else {
for (String label : contextLabels) {
logger.debug("label.trim()={}", label.trim());
labelWords.removeAll(StringUtils.split(label.trim(), PlotConstants.WORD_DELIMITER_PATTERN));
}
return StringUtils.join(labelWords, PlotConstants.WORD_SEPARATOR);
}
}
/** The array return type of {@link #getContextLabels()}, used to
* convert a list into an array.
*/
private static final String[] CONTEXT_LABEL_ARRAY_TYPE = new String[0];
/**
* Gets the labels describing the surrounding context of the table.
* The words in these labels will be stripped during the label
* computation, so that they never appear as row, column, nor cell
* labels.
*
* @return an array containing the context labels, which may be empty
*/
public String[] getContextLabels() {
return globalContextLabels.toArray(CONTEXT_LABEL_ARRAY_TYPE);
}
/**
* Sets the labels describing the surrounding context of the table.
* The words in these labels will be stripped during the label
* computation, so that they never appear as row, column, nor cell
* labels.
*
* @param labels zero or more labels from the surrounding context
*/
public void setContextLabels(String... labels) {
globalContextLabels.clear();
globalContextLabels.addAll(Arrays.asList(labels));
}
public void setPanelContextTitleList(List<String> thePanelContextTitleList) {
panelContextTitleList.clear();
panelContextTitleList.addAll(thePanelContextTitleList);
}
public List<String> getPanelContextTitleList() {
return panelContextTitleList;
}
public void setCanvasContextTitleList(List<String> theCanvasContextTitleList) {
canvasContextTitleList.clear();
canvasContextTitleList.addAll(theCanvasContextTitleList);
}
public List<String> getCanvasContextTitleList() {
return canvasContextTitleList;
}
public void setPanelOrWindowTitle(String panelOrWindowTitle) {
this.panelOrWindowTitle = panelOrWindowTitle;
}
public String getPanelOrWindowTitle() {
return panelOrWindowTitle;
}
public void setCanvasPanelTitle(String canvasPanelTitle) {
this.canvasPanelTitle = canvasPanelTitle;
}
public String getCanvasPanelTitle() {
return canvasPanelTitle;
}
public void setName(String name) {
this.name = name;
}
public String getName() {
return this.name;
}
} | false | fastPlotViews_src_main_java_gov_nasa_arc_mct_fastplot_utils_AbbreviatingPlotLabelingAlgorithm.java |
705 | public class ComponentTraverser {
public static void traverse (Container cont, ComponentProcedure proc) {
for (Component comp : cont.getComponents() ) {
proc.run(comp);
if (comp instanceof Container) {
traverse ((Container) comp, proc);
}
}
}
public interface ComponentProcedure {
public void run(Component c);
}
} | false | fastPlotViews_src_main_java_gov_nasa_arc_mct_fastplot_utils_ComponentTraverser.java |
706 | public interface ComponentProcedure {
public void run(Component c);
} | false | fastPlotViews_src_main_java_gov_nasa_arc_mct_fastplot_utils_ComponentTraverser.java |
707 | public class MenuItemSpinner extends JSpinner {
private static final long serialVersionUID = 1571587288826156261L;
public MenuItemSpinner(SpinnerModel model, final JMenu menu) {
super(model);
final JSpinner spinner = this;
spinner.setBorder(new EmptyBorder(2,2,2,2));
final JFormattedTextField myTextField = ((NumberEditor) spinner
.getEditor()).getTextField();
spinner.addKeyListener(new KeyListener() {
@Override
public void keyTyped(KeyEvent e) {
if ( ! (e.getKeyChar() == KeyEvent.CHAR_UNDEFINED) &&
(e.getKeyCode() == KeyEvent.VK_UNDEFINED) &&
// Apparently, backspace has a key char (although it should not)
(e.getKeyChar() == '0' ||
e.getKeyChar() == '1' ||
e.getKeyChar() == '2' ||
e.getKeyChar() == '3' ||
e.getKeyChar() == '4' ||
e.getKeyChar() == '5' ||
e.getKeyChar() == '6' ||
e.getKeyChar() == '7' ||
e.getKeyChar() == '8' ||
e.getKeyChar() == '9'
) &&
Integer.valueOf(myTextField.getValue() + String.valueOf(e.getKeyChar())).compareTo((Integer)
((SpinnerNumberModel) spinner.getModel()).getMinimum()) > 0 &&
Integer.valueOf(myTextField.getValue() + String.valueOf(e.getKeyChar())).compareTo((Integer)
((SpinnerNumberModel) spinner.getModel()).getMaximum()) < 0 ) {
myTextField.setText(myTextField.getValue() + String.valueOf(e.getKeyChar()));
}
}
@Override
public void keyPressed(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_DELETE ) {
((NumberEditor) spinner.getEditor()).getTextField().setText("");
}
myTextField.grabFocus();
}
@Override
public void keyReleased(KeyEvent e) {
}
});
myTextField.addFocusListener(new FocusListener()
{
@Override
public void focusGained(FocusEvent e) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
myTextField.selectAll();
}
});
}
@Override
public void focusLost(java.awt.event.FocusEvent e) {
}
});
final NumberEditor numberEditor = (NumberEditor) spinner.getEditor();
numberEditor.addKeyListener(new KeyListener() {
@Override
public void keyTyped(KeyEvent e) {
}
@Override
public void keyPressed(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_LEFT &&
numberEditor.getTextField().getCaretPosition() == 0) {
menu.setSelected(true);
}
}
@Override
public void keyReleased(KeyEvent e) {
}
});
myTextField.addKeyListener(new KeyListener() {
@Override
public void keyTyped(KeyEvent e) {
}
@Override
public void keyPressed(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_LEFT &&
numberEditor.getTextField().getCaretPosition() == 0) {
menu.setSelected(true);
menu.grabFocus();
((JPopupMenu) spinner.getParent()).setSelected(menu);
}
}
@Override
public void keyReleased(KeyEvent e) {
}
});
menu.addMenuKeyListener(new MenuKeyListener() {
@Override
public void menuKeyTyped(MenuKeyEvent e) {
}
@Override
public void menuKeyPressed(MenuKeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_RIGHT ) {
spinner.setVisible(true);
spinner.requestFocus();
((NumberEditor) spinner.getEditor()).grabFocus();
}
}
@Override
public void menuKeyReleased(MenuKeyEvent e) {
}
});
}
} | false | fastPlotViews_src_main_java_gov_nasa_arc_mct_fastplot_utils_MenuItemSpinner.java |
708 | spinner.addKeyListener(new KeyListener() {
@Override
public void keyTyped(KeyEvent e) {
if ( ! (e.getKeyChar() == KeyEvent.CHAR_UNDEFINED) &&
(e.getKeyCode() == KeyEvent.VK_UNDEFINED) &&
// Apparently, backspace has a key char (although it should not)
(e.getKeyChar() == '0' ||
e.getKeyChar() == '1' ||
e.getKeyChar() == '2' ||
e.getKeyChar() == '3' ||
e.getKeyChar() == '4' ||
e.getKeyChar() == '5' ||
e.getKeyChar() == '6' ||
e.getKeyChar() == '7' ||
e.getKeyChar() == '8' ||
e.getKeyChar() == '9'
) &&
Integer.valueOf(myTextField.getValue() + String.valueOf(e.getKeyChar())).compareTo((Integer)
((SpinnerNumberModel) spinner.getModel()).getMinimum()) > 0 &&
Integer.valueOf(myTextField.getValue() + String.valueOf(e.getKeyChar())).compareTo((Integer)
((SpinnerNumberModel) spinner.getModel()).getMaximum()) < 0 ) {
myTextField.setText(myTextField.getValue() + String.valueOf(e.getKeyChar()));
}
}
@Override
public void keyPressed(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_DELETE ) {
((NumberEditor) spinner.getEditor()).getTextField().setText("");
}
myTextField.grabFocus();
}
@Override
public void keyReleased(KeyEvent e) {
}
}); | false | fastPlotViews_src_main_java_gov_nasa_arc_mct_fastplot_utils_MenuItemSpinner.java |
709 | {
@Override
public void focusGained(FocusEvent e) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
myTextField.selectAll();
}
});
}
@Override
public void focusLost(java.awt.event.FocusEvent e) {
}
}); | false | fastPlotViews_src_main_java_gov_nasa_arc_mct_fastplot_utils_MenuItemSpinner.java |
710 | SwingUtilities.invokeLater(new Runnable() {
public void run() {
myTextField.selectAll();
}
}); | false | fastPlotViews_src_main_java_gov_nasa_arc_mct_fastplot_utils_MenuItemSpinner.java |
711 | numberEditor.addKeyListener(new KeyListener() {
@Override
public void keyTyped(KeyEvent e) {
}
@Override
public void keyPressed(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_LEFT &&
numberEditor.getTextField().getCaretPosition() == 0) {
menu.setSelected(true);
}
}
@Override
public void keyReleased(KeyEvent e) {
}
}); | false | fastPlotViews_src_main_java_gov_nasa_arc_mct_fastplot_utils_MenuItemSpinner.java |
712 | myTextField.addKeyListener(new KeyListener() {
@Override
public void keyTyped(KeyEvent e) {
}
@Override
public void keyPressed(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_LEFT &&
numberEditor.getTextField().getCaretPosition() == 0) {
menu.setSelected(true);
menu.grabFocus();
((JPopupMenu) spinner.getParent()).setSelected(menu);
}
}
@Override
public void keyReleased(KeyEvent e) {
}
}); | false | fastPlotViews_src_main_java_gov_nasa_arc_mct_fastplot_utils_MenuItemSpinner.java |
713 | menu.addMenuKeyListener(new MenuKeyListener() {
@Override
public void menuKeyTyped(MenuKeyEvent e) {
}
@Override
public void menuKeyPressed(MenuKeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_RIGHT ) {
spinner.setVisible(true);
spinner.requestFocus();
((NumberEditor) spinner.getEditor()).grabFocus();
}
}
@Override
public void menuKeyReleased(MenuKeyEvent e) {
}
}); | false | fastPlotViews_src_main_java_gov_nasa_arc_mct_fastplot_utils_MenuItemSpinner.java |
714 | public class StringUtils {
/**
* Splits a string into words and returns the result as a list.
* Empty words are never returned. This is slightly different
* behavior than that of {@link String#split(String)}, which will
* return an array of one element, an empty string, if no words
* are found.
*
* @param s the string to split
* @param delimiterPattern the regular expression representing the word delimiters
* @return the words found, as a list, or an empty list if no words found
*/
public static List<String> split(String s, Pattern delimiterPattern) {
String[] words = delimiterPattern.split(s);
// Add all nonempty words to the result.
List<String> result = new ArrayList<String>();
for (String w : words) {
if (w.length() > 0) {
result.add(w);
}
}
return result;
}
/**
* Joins a list of words together, separated by a separator string.
*
* @param words the list of words to join, which may be empty
* @param separator the string to insert between the words
* @return the joined string
*/
public static String join(List<String> words, String separator) {
StringBuilder s = new StringBuilder();
for (String w : words) {
if (s.length() > 0) {
s.append(separator);
}
s.append(w);
}
return s.toString();
}
} | false | fastPlotViews_src_main_java_gov_nasa_arc_mct_fastplot_utils_StringUtils.java |
715 | public class TruncatingLabel extends JLabel {
private static final long serialVersionUID = 2217561217187839569L;
@Override
public void paint(Graphics g) {
super.paint(g);
if (getParent().getWidth() < getWidth()) {
int ellipseWidth;
if (g instanceof Graphics2D) {
TextLayout tl = new TextLayout(PlotConstants.LEGEND_ELLIPSES,
g.getFont(), ((Graphics2D) g).getFontRenderContext());
ellipseWidth = tl.getPixelBounds(null, 0, 0).width + 1;
} else {
ellipseWidth = 10;
}
g.setColor(getBackground());
g.fillRect(getParent().getWidth()-ellipseWidth, 0, ellipseWidth, getHeight());
g.setColor(getForeground());
g.drawString(PlotConstants.LEGEND_ELLIPSES, getParent().getWidth()-ellipseWidth,
getHeight() - g.getFontMetrics().getDescent() - 1);
}
}
} | false | fastPlotViews_src_main_java_gov_nasa_arc_mct_fastplot_utils_TruncatingLabel.java |
716 | public class Axis {
private PinSupport pinSupport = new PinSupport() {
protected void informPinned(boolean pinned) {
Axis.this.informPinned(pinned);
}
};
private boolean zoomed;
/**
* Returns true if the axis is pinned.
* @return true if the axis is pinned
*/
public boolean isPinned() {
return pinSupport.isPinned();
}
/**
* Called when the axis is pinned or unpinned.
* Do not call directly; this gets called from {@link Pin#informPinned(boolean)}.
* @param pinned true if it is pinned
*/
protected void informPinned(boolean pinned) {
}
/**
* Returns true if the axis is zoomed. (True means that the zoom level is non-default.)
* @return true if the axis is zoomed
*/
public boolean isZoomed() {
return zoomed;
}
/**
* Sets whether or not the axis is zoomed. (True means that the zoom level is non-default.)
* @param zoomed true if the axis is zoomed
*/
public void setZoomed(boolean zoomed) {
this.zoomed = zoomed;
}
/**
* Returns true if the axis is in a default state, i.e. not pinned and not zoomed.
* @return true if the axis is in a default state
*/
public boolean isInDefaultState() {
return !pinSupport.isPinned() && !zoomed;
}
/**
* Creates a new pin for this axis.
* The axis is pinned if any of its pins are pinned.
* @return new pin
*/
public Pinnable createPin() {
return pinSupport.createPin();
}
} | false | fastPlotViews_src_main_java_gov_nasa_arc_mct_fastplot_view_Axis.java |
717 | private PinSupport pinSupport = new PinSupport() {
protected void informPinned(boolean pinned) {
Axis.this.informPinned(pinned);
}
}; | false | fastPlotViews_src_main_java_gov_nasa_arc_mct_fastplot_view_Axis.java |
718 | public enum IconLoader {
INSTANCE;
public static enum Icons {
PLOT_TIME_ON_X_NORMAL,
PLOT_TIME_ON_X_REVERSED,
PLOT_TIME_ON_Y_NORMAL,
PLOT_TIME_ON_Y_REVERSED,
PLOT_UP_ARROW_SOLID_ICON,
PLOT_UP_ARROW_HOLLOW_ICON,
PLOT_UP_ARROW_TRANSLUCENT_ICON,
PLOT_DOWN_ARROW_SOLID_ICON,
PLOT_DOWN_ARROW_HOLLOW_ICON,
PLOT_DOWN_ARROW_TRANSLUCENT_ICON,
PLOT_RIGHT_ARROW_SOLID_ICON,
PLOT_RIGHT_ARROW_HOLLOW_ICON,
PLOT_RIGHT_ARROW_TRANSLUCENT_ICON,
PLOT_LEFT_ARROW_SOLID_ICON,
PLOT_LEFT_ARROW_HOLLOW_ICON,
PLOT_LEFT_ARROW_TRANSLUCENT_ICON,
PLOT_PAUSE_ICON,
PLOT_PLAY_ICON,
PLOT_PAN_DOWN_ARROW_ICON,
PLOT_PAN_UP_ARROW_ICON,
PLOT_PAN_LEFT_ARROW_ICON,
PLOT_PAN_RIGHT_ARROW_ICON,
PLOT_ZOOM_IN_X_ICON,
PLOT_ZOOM_OUT_X_ICON,
PLOT_ZOOM_IN_Y_ICON,
PLOT_ZOOM_OUT_Y_ICON,
PLOT_CORNER_RESET_BUTTON_TOP_RIGHT_GREY,
PLOT_CORNER_RESET_BUTTON_TOP_RIGHT_ORANGE,
PLOT_CORNER_RESET_BUTTON_TOP_LEFT_GREY,
PLOT_CORNER_RESET_BUTTON_BOTTOM_RIGHT_GREY,
PLOT_CORNER_RESET_BUTTON_BOTTOM_LEFT_GREY
}
private static ImageIcon plotTimeOnXNormalImage;
private static ImageIcon plotTimeOnXReversedImage;
private static ImageIcon plotTimeOnYNormalImage;
private static ImageIcon plotTimeOnYReversedImage;
private static ImageIcon plotUpArrowSolidImage = null;
private static ImageIcon plotUpArrowHollowImage = null;
private static ImageIcon plotUpArrowTranslucentImage = null;
private static ImageIcon plotDownArrowSolidImage = null;
private static ImageIcon plotDownArrowHollowImage = null;
private static ImageIcon plotDownArrowTranslucentImage = null;
private static ImageIcon plotLeftArrowSolidImage = null;
private static ImageIcon plotLeftArrowHollowImage = null;
private static ImageIcon plotLeftArrowTranslucentImage = null;
private static ImageIcon plotRightArrowSolidImage = null;
private static ImageIcon plotRightArrowHollowImage = null;
private static ImageIcon plotRightArrowTranslucentImage = null;
private static ImageIcon plotPauseIconImage = null;
private static ImageIcon plotPlayIconImage = null;
private static ImageIcon plotPanDownArrowImage = null;
private static ImageIcon plotPanUpArrowImage = null;
private static ImageIcon plotPanLeftArrowImage = null;
private static ImageIcon plotPanRightArrowImage = null;
private static ImageIcon plotZoomInXImage = null;
private static ImageIcon plotZoomOutXImage = null;
private static ImageIcon plotZoomInYImage = null;
private static ImageIcon plotZoomOutYImage = null;
private static ImageIcon plotCornerResetButtonTopRightGreyImage = null;
private static ImageIcon plotCornerResetButtonTopRightOrangeImage = null;
private static ImageIcon plotCornerResetButtonTopLeftGreyImage = null;
private static ImageIcon plotCornerResetButtonBottomRightGreyImage = null;
private static ImageIcon plotCornerResetButtonBottomLeftGreyImage = null;
public ImageIcon getIcon(Icons iconID) {
switch(iconID) {
case PLOT_TIME_ON_X_NORMAL:
if (plotTimeOnXNormalImage == null) {
plotTimeOnXNormalImage = new ImageIcon(
getClass().getClassLoader().getResource("images/plot_Xtime_maxRight.png"));
}
return plotTimeOnXNormalImage;
case PLOT_TIME_ON_X_REVERSED:
if (plotTimeOnXReversedImage == null) {
plotTimeOnXReversedImage = new ImageIcon(
getClass().getClassLoader().getResource("images/plot_Xtime_maxLeft.png"));
}
return plotTimeOnXReversedImage;
case PLOT_TIME_ON_Y_NORMAL:
if (plotTimeOnYNormalImage == null) {
plotTimeOnYNormalImage = new ImageIcon(
getClass().getClassLoader().getResource("images/plot_Ytime_maxTop.png"));
}
return plotTimeOnYNormalImage;
case PLOT_TIME_ON_Y_REVERSED:
if (plotTimeOnYReversedImage == null) {
plotTimeOnYReversedImage = new ImageIcon(
getClass().getClassLoader().getResource("images/plot_Ytime_maxBottom.png"));
}
return plotTimeOnYReversedImage;
case PLOT_UP_ARROW_SOLID_ICON:
if (plotUpArrowSolidImage == null)
plotUpArrowSolidImage = new ImageIcon(getClass().getClassLoader().getResource("images/plot_up_arrow_solid.png"));
return plotUpArrowSolidImage;
case PLOT_UP_ARROW_HOLLOW_ICON:
if (plotUpArrowHollowImage == null)
plotUpArrowHollowImage = new ImageIcon(getClass().getClassLoader().getResource("images/plot_up_arrow_hollow.png"));
return plotUpArrowHollowImage;
case PLOT_UP_ARROW_TRANSLUCENT_ICON:
if (plotUpArrowTranslucentImage == null)
plotUpArrowTranslucentImage = new ImageIcon(getClass().getClassLoader().getResource("images/plot_up_arrow_translucent.png"));
return plotUpArrowTranslucentImage;
case PLOT_DOWN_ARROW_SOLID_ICON:
if (plotDownArrowSolidImage == null)
plotDownArrowSolidImage = new ImageIcon(getClass().getClassLoader().getResource("images/plot_down_arrow_solid.png"));
return plotDownArrowSolidImage;
case PLOT_DOWN_ARROW_HOLLOW_ICON:
if (plotDownArrowHollowImage == null)
plotDownArrowHollowImage = new ImageIcon(getClass().getClassLoader().getResource("images/plot_down_arrow_hollow.png"));
return plotDownArrowHollowImage;
case PLOT_DOWN_ARROW_TRANSLUCENT_ICON:
if (plotDownArrowTranslucentImage == null)
plotDownArrowTranslucentImage = new ImageIcon(getClass().getClassLoader().getResource("images/plot_down_arrow_translucent.png"));
return plotDownArrowTranslucentImage;
case PLOT_LEFT_ARROW_SOLID_ICON:
if (plotLeftArrowSolidImage == null)
plotLeftArrowSolidImage = new ImageIcon(getClass().getClassLoader().getResource("images/plot_left_arrow_solid.png"));
return plotLeftArrowSolidImage;
case PLOT_LEFT_ARROW_HOLLOW_ICON:
if (plotLeftArrowHollowImage == null)
plotLeftArrowHollowImage = new ImageIcon(getClass().getClassLoader().getResource("images/plot_left_arrow_hollow.png"));
return plotLeftArrowHollowImage;
case PLOT_LEFT_ARROW_TRANSLUCENT_ICON:
if (plotLeftArrowTranslucentImage == null)
plotLeftArrowTranslucentImage = new ImageIcon(getClass().getClassLoader().getResource("images/plot_left_arrow_translucent.png"));
return plotLeftArrowTranslucentImage;
case PLOT_RIGHT_ARROW_SOLID_ICON:
if (plotRightArrowSolidImage == null)
plotRightArrowSolidImage = new ImageIcon(getClass().getClassLoader().getResource("images/plot_right_arrow_solid.png"));
return plotRightArrowSolidImage;
case PLOT_RIGHT_ARROW_HOLLOW_ICON:
if (plotRightArrowHollowImage == null)
plotRightArrowHollowImage = new ImageIcon(getClass().getClassLoader().getResource("images/plot_right_arrow_hollow.png"));
return plotRightArrowHollowImage;
case PLOT_RIGHT_ARROW_TRANSLUCENT_ICON:
if (plotRightArrowTranslucentImage == null)
plotRightArrowTranslucentImage = new ImageIcon(getClass().getClassLoader().getResource("images/plot_right_arrow_translucent.png"));
return plotRightArrowTranslucentImage;
case PLOT_PAUSE_ICON:
if (plotPauseIconImage == null) {
plotPauseIconImage = new ImageIcon(
getClass().getClassLoader().getResource("images/plot_pause_button.png"));
}
return plotPauseIconImage;
case PLOT_PLAY_ICON:
if (plotPlayIconImage == null) {
plotPlayIconImage = new ImageIcon(
getClass().getClassLoader().getResource("images/plot_play_button.png"));
}
return plotPlayIconImage;
case PLOT_PAN_DOWN_ARROW_ICON:
if (plotPanDownArrowImage == null) {
plotPanDownArrowImage = new ImageIcon(
getClass().getClassLoader().getResource("images/plot_pan_down_arrow.png"));
}
return plotPanDownArrowImage;
case PLOT_PAN_UP_ARROW_ICON:
if (plotPanUpArrowImage == null) {
plotPanUpArrowImage = new ImageIcon(
getClass().getClassLoader().getResource("images/plot_pan_up_arrow.png"));
}
return plotPanUpArrowImage;
case PLOT_PAN_LEFT_ARROW_ICON:
if (plotPanLeftArrowImage == null) {
plotPanLeftArrowImage = new ImageIcon(
getClass().getClassLoader().getResource("images/plot_pan_left_arrow.png"));
}
return plotPanLeftArrowImage;
case PLOT_PAN_RIGHT_ARROW_ICON:
if (plotPanRightArrowImage == null) {
plotPanRightArrowImage = new ImageIcon(
getClass().getClassLoader().getResource("images/plot_pan_right_arrow.png"));
}
return plotPanRightArrowImage;
case PLOT_ZOOM_IN_X_ICON:
if (plotZoomInXImage == null) {
plotZoomInXImage = new ImageIcon(
getClass().getClassLoader().getResource("images/plot_zoom_magnifier_x_axis_plus.png"));
}
return plotZoomInXImage;
case PLOT_ZOOM_OUT_X_ICON:
if (plotZoomOutXImage == null) {
plotZoomOutXImage = new ImageIcon(
getClass().getClassLoader().getResource("images/plot_zoom_magnifier_x_axis_neg.png"));
}
return plotZoomOutXImage;
case PLOT_ZOOM_IN_Y_ICON:
if (plotZoomInYImage == null) {
plotZoomInYImage = new ImageIcon(
getClass().getClassLoader().getResource("images/plot_zoom_magnifier_y_axis_plus.png"));
}
return plotZoomInYImage;
case PLOT_ZOOM_OUT_Y_ICON:
if (plotZoomOutYImage == null) {
plotZoomOutYImage = new ImageIcon(
getClass().getClassLoader().getResource("images/plot_zoom_magnifier_y_axis_neg.png"));
}
return plotZoomOutYImage;
case PLOT_CORNER_RESET_BUTTON_TOP_RIGHT_GREY:
if (plotCornerResetButtonTopRightGreyImage == null) {
plotCornerResetButtonTopRightGreyImage = new ImageIcon(
getClass().getClassLoader().getResource("images/plot_corner_reset_button_top_right_grey.png"));
}
return plotCornerResetButtonTopRightGreyImage;
case PLOT_CORNER_RESET_BUTTON_TOP_RIGHT_ORANGE:
if (plotCornerResetButtonTopRightOrangeImage == null) {
plotCornerResetButtonTopRightOrangeImage = new ImageIcon(
getClass().getClassLoader().getResource("images/plot_corner_reset_button_top_right_orange.png"));
}
return plotCornerResetButtonTopRightOrangeImage;
case PLOT_CORNER_RESET_BUTTON_TOP_LEFT_GREY:
if (plotCornerResetButtonTopLeftGreyImage == null) {
plotCornerResetButtonTopLeftGreyImage = new ImageIcon(
getClass().getClassLoader().getResource("images/plot_corner_reset_button_top_left_grey.png"));
}
return plotCornerResetButtonTopLeftGreyImage;
case PLOT_CORNER_RESET_BUTTON_BOTTOM_LEFT_GREY:
if (plotCornerResetButtonBottomLeftGreyImage == null) {
plotCornerResetButtonBottomLeftGreyImage = new ImageIcon(
getClass().getClassLoader().getResource("images/plot_corner_reset_button_bottom_left_grey.png"));
}
return plotCornerResetButtonBottomLeftGreyImage;
case PLOT_CORNER_RESET_BUTTON_BOTTOM_RIGHT_GREY:
if (plotCornerResetButtonBottomRightGreyImage == null) {
plotCornerResetButtonBottomRightGreyImage = new ImageIcon(
getClass().getClassLoader().getResource("images/plot_corner_reset_button_bottom_right_grey.png"));
}
return plotCornerResetButtonBottomRightGreyImage;
default:
return null;
}
}
} | false | fastPlotViews_src_main_java_gov_nasa_arc_mct_fastplot_view_IconLoader.java |
719 | public static enum Icons {
PLOT_TIME_ON_X_NORMAL,
PLOT_TIME_ON_X_REVERSED,
PLOT_TIME_ON_Y_NORMAL,
PLOT_TIME_ON_Y_REVERSED,
PLOT_UP_ARROW_SOLID_ICON,
PLOT_UP_ARROW_HOLLOW_ICON,
PLOT_UP_ARROW_TRANSLUCENT_ICON,
PLOT_DOWN_ARROW_SOLID_ICON,
PLOT_DOWN_ARROW_HOLLOW_ICON,
PLOT_DOWN_ARROW_TRANSLUCENT_ICON,
PLOT_RIGHT_ARROW_SOLID_ICON,
PLOT_RIGHT_ARROW_HOLLOW_ICON,
PLOT_RIGHT_ARROW_TRANSLUCENT_ICON,
PLOT_LEFT_ARROW_SOLID_ICON,
PLOT_LEFT_ARROW_HOLLOW_ICON,
PLOT_LEFT_ARROW_TRANSLUCENT_ICON,
PLOT_PAUSE_ICON,
PLOT_PLAY_ICON,
PLOT_PAN_DOWN_ARROW_ICON,
PLOT_PAN_UP_ARROW_ICON,
PLOT_PAN_LEFT_ARROW_ICON,
PLOT_PAN_RIGHT_ARROW_ICON,
PLOT_ZOOM_IN_X_ICON,
PLOT_ZOOM_OUT_X_ICON,
PLOT_ZOOM_IN_Y_ICON,
PLOT_ZOOM_OUT_Y_ICON,
PLOT_CORNER_RESET_BUTTON_TOP_RIGHT_GREY,
PLOT_CORNER_RESET_BUTTON_TOP_RIGHT_ORANGE,
PLOT_CORNER_RESET_BUTTON_TOP_LEFT_GREY,
PLOT_CORNER_RESET_BUTTON_BOTTOM_RIGHT_GREY,
PLOT_CORNER_RESET_BUTTON_BOTTOM_LEFT_GREY
} | false | fastPlotViews_src_main_java_gov_nasa_arc_mct_fastplot_view_IconLoader.java |
720 | public class LegendEntryPopupMenuFactory {
private static final ResourceBundle BUNDLE =
ResourceBundle.getBundle(LegendEntryPopupMenuFactory.class.getName().substring(0,
LegendEntryPopupMenuFactory.class.getName().lastIndexOf("."))+".Bundle");
private PlotViewManifestation manifestation;
public LegendEntryPopupMenuFactory(PlotViewManifestation targetPlotManifestation) {
manifestation = targetPlotManifestation;
}
/**
* Get a popup menu for a specified legend entry
* @param entry the legend entry to produce a popup menu
* @return a popup menu with options appropriate to the specified legend entry
*/
public JPopupMenu getPopup(LegendEntry entry) {
LegendEntryPopup popup = new LegendEntryPopup(manifestation, entry);
return popup;
}
private class LegendEntryPopup extends JPopupMenu {
private static final long serialVersionUID = -4846098785335776279L;
private int spinnerValue;
public LegendEntryPopup(final PlotViewManifestation manifestation, final LegendEntry legendEntry) {
super();
if (!manifestation.isLocked()) {
String name = legendEntry.getComputedBaseDisplayName();
spinnerValue = legendEntry.getNumberRegressionPoints();
if (name.isEmpty()) name = legendEntry.getFullBaseDisplayName();
final LineSettings settings = legendEntry.getLineSettings();
// Color submenu
String subMenuText = String.format(BUNDLE.getString("SelectColor.label"), name);
JMenu subMenu = new JMenu(subMenuText);
Color currentColor = legendEntry.getForeground();
for (int i = 0; i < PlotConstants.MAX_NUMBER_OF_DATA_ITEMS_ON_A_PLOT; i++) {
JMenuItem item = new JRadioButtonMenuItem("",
new SolidColorIcon(PlotLineColorPalette.getColor(i)),
(currentColor == PlotLineColorPalette.getColor(i))
);
final int colorIndex = i;
item.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
legendEntry.setForeground(PlotLineColorPalette.getColor(colorIndex));
manifestation.persistPlotLineSettings();
}
});
subMenu.add(item);
}
add(subMenu);
// Thickness submenu
subMenuText = String.format(BUNDLE.getString("SelectThickness.label"), name);
subMenu = new JMenu(subMenuText);
for (int i = 1; i <= PlotConstants.MAX_LINE_THICKNESS; i++) {
JMenuItem item = new JRadioButtonMenuItem("" + i,
(settings.getThickness() == i));
final int thickness = i;
item.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
settings.setThickness(thickness);
legendEntry.setLineSettings(settings);
manifestation.persistPlotLineSettings();
}
});
subMenu.add(item);
}
add(subMenu);
// Marker submenu
if (manifestation.getPlot() != null &&
manifestation.getPlot().getPlotLineDraw().drawMarkers()) {
subMenuText = String.format(BUNDLE.getString("SelectMarker.label"), name);
subMenu = new JMenu(subMenuText);
for (int i = 0; i < PlotConstants.MAX_NUMBER_OF_DATA_ITEMS_ON_A_PLOT; i++) {
JMenuItem item = new JRadioButtonMenuItem("",
new PlotMarkerIcon(PlotLineShapePalette.getShape(i), false),
(settings.getMarker() == i && !settings.getUseCharacter()));
item.setForeground(legendEntry.getForeground());
final int marker = i;
item.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
settings.setMarker(marker);
settings.setUseCharacter(false);
legendEntry.setLineSettings(settings);
manifestation.persistPlotLineSettings();
}
});
subMenu.add(item);
}
JMenuItem other = new JRadioButtonMenuItem(BUNDLE.getString("SelectCharacter.label"),
settings.getUseCharacter());
if (!settings.getCharacter().isEmpty()) {
FontRenderContext frc = ((Graphics2D) manifestation.getGraphics()).getFontRenderContext();
other.setIcon(new PlotMarkerIcon(
PlotLineShapePalette.getShape(settings.getCharacter(), frc),
PlotLineColorPalette.getColor(settings.getColorIndex()),
false));
}
other.addActionListener( new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
final CharacterDialog dialog = new CharacterDialog();
dialog.setInitialString(settings.getCharacter());
dialog.ok.addActionListener( new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
settings.setCharacter(dialog.field.getText().trim());
settings.setUseCharacter(true);
legendEntry.setLineSettings(settings);
manifestation.persistPlotLineSettings();
}
});
dialog.setVisible(true);
}
});
subMenu.add(other);
add(subMenu);
}
// Regression line
addSeparator();
String subMenuText2 = String.format(BUNDLE.getString("RegressionPointsLabel"),
name);
final JMenuItem regressionLineCheckBox = new JCheckBoxMenuItem(BUNDLE.getString("RegressionLineLabel"),false);
final JMenu regressionMenu = new JMenu(subMenuText2);
SpinnerModel pointsModel = new SpinnerNumberModel(legendEntry.getNumberRegressionPoints(), 2, 100, 1);
final JSpinner spinner = new MenuItemSpinner(pointsModel, regressionMenu);
spinner.setPreferredSize(new Dimension(50, 20));
spinner.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
legendEntry.setNumberRegressionPoints(Integer.parseInt(((JSpinner)e.getSource()).getValue().toString()));
}
});
addPopupMenuListener(new PopupMenuListener() {
@Override
public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
// TODO Auto-generated method stub
}
@Override
public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
if (spinnerValue != Integer.parseInt(spinner.getValue().toString())) {
manifestation.persistPlotLineSettings();
}
}
@Override
public void popupMenuCanceled(PopupMenuEvent e) {
// TODO Auto-generated method stub
}
});
regressionLineCheckBox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
AbstractButton abstractButton = (AbstractButton) e.getSource();
if (abstractButton.getModel().isSelected()) {
legendEntry.setHasRegressionLine(true);
} else {
legendEntry.setHasRegressionLine(false);
}
manifestation.persistPlotLineSettings();
}
});
if (legendEntry.hasRegressionLine()) {
regressionLineCheckBox.setSelected(true);
} else {
regressionLineCheckBox.setSelected(false);
}
add(regressionLineCheckBox);
regressionMenu.add(spinner);
add(regressionMenu);
}
}
private class SolidColorIcon implements Icon {
private Color iconColor;
public SolidColorIcon (Color c) {
iconColor = c;
}
@Override
public int getIconHeight() {
return 12;
}
@Override
public int getIconWidth() {
return 48;
}
@Override
public void paintIcon(Component arg0, Graphics g, int x,
int y) {
g.setColor(iconColor);
g.fillRect(x, y, getIconWidth(), getIconHeight() - 1);
g.setColor(iconColor.darker());
g.drawRect(x, y, getIconWidth(), getIconHeight() - 1);
}
}
private class CharacterDialog extends JDialog {
private static final long serialVersionUID = 1644116578638815212L;
private JTextField field = new JTextField(1);
private JButton ok, cancel;
public CharacterDialog() {
super((Frame) SwingUtilities.windowForComponent(manifestation));
Frame f = (Frame) SwingUtilities.windowForComponent(manifestation);
setTitle(BUNDLE.getString("SelectCharacter.title") + " - " +
f.getTitle() + " - " +
manifestation.getInfo().getViewName());
setLocationRelativeTo((Frame) SwingUtilities.windowForComponent(manifestation));
ActionListener closer = new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
setVisible(false);
dispose();
}
};
ok = new JButton("OK");
cancel = new JButton("Cancel");
ok .addActionListener(closer);
cancel.addActionListener(closer);
final Document doc = field.getDocument();
if (doc instanceof AbstractDocument) {
AbstractDocument ad = (AbstractDocument) doc;
ad.setDocumentFilter(new DocumentFilter() {
@Override
public void insertString(FilterBypass bypass, int offset,
String str, AttributeSet attr)
throws BadLocationException {
if (doc.getLength() + str.length() < 2 && !str.trim().isEmpty()) {
super.insertString(bypass, offset, str, attr);
}
}
@Override
public void replace(FilterBypass bypass, int start,
int length, String str, AttributeSet attr)
throws BadLocationException {
if (doc.getLength() + str.length() < 2 && !str.trim().isEmpty()) {
super.replace(bypass, start, length, str, attr);
}
}
});
}
doc.addDocumentListener(new DocumentListener() {
@Override
public void changedUpdate(DocumentEvent arg0) {
ok.setEnabled(doc.getLength() == 1);
}
@Override
public void insertUpdate(DocumentEvent arg0) {
ok.setEnabled(doc.getLength() == 1);
}
@Override
public void removeUpdate(DocumentEvent arg0) {
ok.setEnabled(doc.getLength() == 1);
}
});
JPanel panel = new JPanel();
JLabel label = new JLabel(BUNDLE.getString("SelectCharacterDescription.label"));
SpringLayout layout = new SpringLayout();
panel.setLayout(layout);
panel .add(label);
panel .add(field);
panel .add(ok);
panel .add(cancel);
layout.putConstraint(SpringLayout.WEST , label , 0, SpringLayout.WEST , panel );
layout.putConstraint(SpringLayout.WEST , field , 12, SpringLayout.EAST , label );
layout.putConstraint(SpringLayout.EAST , panel , 0, SpringLayout.EAST , field );
layout.putConstraint(SpringLayout.EAST , cancel, 0, SpringLayout.EAST , panel );
layout.putConstraint(SpringLayout.EAST , ok , -5, SpringLayout.WEST , cancel);
layout.putConstraint(SpringLayout.NORTH, label , 0, SpringLayout.NORTH, panel );
layout.putConstraint(SpringLayout.NORTH, field , 0, SpringLayout.NORTH, panel );
layout.putConstraint(SpringLayout.NORTH, cancel, 17, SpringLayout.SOUTH, field );
layout.putConstraint(SpringLayout.NORTH, ok , 17, SpringLayout.SOUTH, field );
layout.putConstraint(SpringLayout.SOUTH, panel, 0, SpringLayout.SOUTH, cancel);
layout.putConstraint(SpringLayout.SOUTH, panel , 0, SpringLayout.SOUTH, ok );
panel.setBorder(BorderFactory.createEmptyBorder(12, 12, 11, 11));
getContentPane().add(panel);
pack();
}
private void setInitialString (String s) {
field.setText(s.trim());
ok.setEnabled(!s.trim().isEmpty());
}
}
}
} | false | fastPlotViews_src_main_java_gov_nasa_arc_mct_fastplot_view_LegendEntryPopupMenuFactory.java |
721 | private class LegendEntryPopup extends JPopupMenu {
private static final long serialVersionUID = -4846098785335776279L;
private int spinnerValue;
public LegendEntryPopup(final PlotViewManifestation manifestation, final LegendEntry legendEntry) {
super();
if (!manifestation.isLocked()) {
String name = legendEntry.getComputedBaseDisplayName();
spinnerValue = legendEntry.getNumberRegressionPoints();
if (name.isEmpty()) name = legendEntry.getFullBaseDisplayName();
final LineSettings settings = legendEntry.getLineSettings();
// Color submenu
String subMenuText = String.format(BUNDLE.getString("SelectColor.label"), name);
JMenu subMenu = new JMenu(subMenuText);
Color currentColor = legendEntry.getForeground();
for (int i = 0; i < PlotConstants.MAX_NUMBER_OF_DATA_ITEMS_ON_A_PLOT; i++) {
JMenuItem item = new JRadioButtonMenuItem("",
new SolidColorIcon(PlotLineColorPalette.getColor(i)),
(currentColor == PlotLineColorPalette.getColor(i))
);
final int colorIndex = i;
item.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
legendEntry.setForeground(PlotLineColorPalette.getColor(colorIndex));
manifestation.persistPlotLineSettings();
}
});
subMenu.add(item);
}
add(subMenu);
// Thickness submenu
subMenuText = String.format(BUNDLE.getString("SelectThickness.label"), name);
subMenu = new JMenu(subMenuText);
for (int i = 1; i <= PlotConstants.MAX_LINE_THICKNESS; i++) {
JMenuItem item = new JRadioButtonMenuItem("" + i,
(settings.getThickness() == i));
final int thickness = i;
item.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
settings.setThickness(thickness);
legendEntry.setLineSettings(settings);
manifestation.persistPlotLineSettings();
}
});
subMenu.add(item);
}
add(subMenu);
// Marker submenu
if (manifestation.getPlot() != null &&
manifestation.getPlot().getPlotLineDraw().drawMarkers()) {
subMenuText = String.format(BUNDLE.getString("SelectMarker.label"), name);
subMenu = new JMenu(subMenuText);
for (int i = 0; i < PlotConstants.MAX_NUMBER_OF_DATA_ITEMS_ON_A_PLOT; i++) {
JMenuItem item = new JRadioButtonMenuItem("",
new PlotMarkerIcon(PlotLineShapePalette.getShape(i), false),
(settings.getMarker() == i && !settings.getUseCharacter()));
item.setForeground(legendEntry.getForeground());
final int marker = i;
item.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
settings.setMarker(marker);
settings.setUseCharacter(false);
legendEntry.setLineSettings(settings);
manifestation.persistPlotLineSettings();
}
});
subMenu.add(item);
}
JMenuItem other = new JRadioButtonMenuItem(BUNDLE.getString("SelectCharacter.label"),
settings.getUseCharacter());
if (!settings.getCharacter().isEmpty()) {
FontRenderContext frc = ((Graphics2D) manifestation.getGraphics()).getFontRenderContext();
other.setIcon(new PlotMarkerIcon(
PlotLineShapePalette.getShape(settings.getCharacter(), frc),
PlotLineColorPalette.getColor(settings.getColorIndex()),
false));
}
other.addActionListener( new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
final CharacterDialog dialog = new CharacterDialog();
dialog.setInitialString(settings.getCharacter());
dialog.ok.addActionListener( new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
settings.setCharacter(dialog.field.getText().trim());
settings.setUseCharacter(true);
legendEntry.setLineSettings(settings);
manifestation.persistPlotLineSettings();
}
});
dialog.setVisible(true);
}
});
subMenu.add(other);
add(subMenu);
}
// Regression line
addSeparator();
String subMenuText2 = String.format(BUNDLE.getString("RegressionPointsLabel"),
name);
final JMenuItem regressionLineCheckBox = new JCheckBoxMenuItem(BUNDLE.getString("RegressionLineLabel"),false);
final JMenu regressionMenu = new JMenu(subMenuText2);
SpinnerModel pointsModel = new SpinnerNumberModel(legendEntry.getNumberRegressionPoints(), 2, 100, 1);
final JSpinner spinner = new MenuItemSpinner(pointsModel, regressionMenu);
spinner.setPreferredSize(new Dimension(50, 20));
spinner.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
legendEntry.setNumberRegressionPoints(Integer.parseInt(((JSpinner)e.getSource()).getValue().toString()));
}
});
addPopupMenuListener(new PopupMenuListener() {
@Override
public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
// TODO Auto-generated method stub
}
@Override
public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
if (spinnerValue != Integer.parseInt(spinner.getValue().toString())) {
manifestation.persistPlotLineSettings();
}
}
@Override
public void popupMenuCanceled(PopupMenuEvent e) {
// TODO Auto-generated method stub
}
});
regressionLineCheckBox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
AbstractButton abstractButton = (AbstractButton) e.getSource();
if (abstractButton.getModel().isSelected()) {
legendEntry.setHasRegressionLine(true);
} else {
legendEntry.setHasRegressionLine(false);
}
manifestation.persistPlotLineSettings();
}
});
if (legendEntry.hasRegressionLine()) {
regressionLineCheckBox.setSelected(true);
} else {
regressionLineCheckBox.setSelected(false);
}
add(regressionLineCheckBox);
regressionMenu.add(spinner);
add(regressionMenu);
}
}
private class SolidColorIcon implements Icon {
private Color iconColor;
public SolidColorIcon (Color c) {
iconColor = c;
}
@Override
public int getIconHeight() {
return 12;
}
@Override
public int getIconWidth() {
return 48;
}
@Override
public void paintIcon(Component arg0, Graphics g, int x,
int y) {
g.setColor(iconColor);
g.fillRect(x, y, getIconWidth(), getIconHeight() - 1);
g.setColor(iconColor.darker());
g.drawRect(x, y, getIconWidth(), getIconHeight() - 1);
}
}
private class CharacterDialog extends JDialog {
private static final long serialVersionUID = 1644116578638815212L;
private JTextField field = new JTextField(1);
private JButton ok, cancel;
public CharacterDialog() {
super((Frame) SwingUtilities.windowForComponent(manifestation));
Frame f = (Frame) SwingUtilities.windowForComponent(manifestation);
setTitle(BUNDLE.getString("SelectCharacter.title") + " - " +
f.getTitle() + " - " +
manifestation.getInfo().getViewName());
setLocationRelativeTo((Frame) SwingUtilities.windowForComponent(manifestation));
ActionListener closer = new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
setVisible(false);
dispose();
}
};
ok = new JButton("OK");
cancel = new JButton("Cancel");
ok .addActionListener(closer);
cancel.addActionListener(closer);
final Document doc = field.getDocument();
if (doc instanceof AbstractDocument) {
AbstractDocument ad = (AbstractDocument) doc;
ad.setDocumentFilter(new DocumentFilter() {
@Override
public void insertString(FilterBypass bypass, int offset,
String str, AttributeSet attr)
throws BadLocationException {
if (doc.getLength() + str.length() < 2 && !str.trim().isEmpty()) {
super.insertString(bypass, offset, str, attr);
}
}
@Override
public void replace(FilterBypass bypass, int start,
int length, String str, AttributeSet attr)
throws BadLocationException {
if (doc.getLength() + str.length() < 2 && !str.trim().isEmpty()) {
super.replace(bypass, start, length, str, attr);
}
}
});
}
doc.addDocumentListener(new DocumentListener() {
@Override
public void changedUpdate(DocumentEvent arg0) {
ok.setEnabled(doc.getLength() == 1);
}
@Override
public void insertUpdate(DocumentEvent arg0) {
ok.setEnabled(doc.getLength() == 1);
}
@Override
public void removeUpdate(DocumentEvent arg0) {
ok.setEnabled(doc.getLength() == 1);
}
});
JPanel panel = new JPanel();
JLabel label = new JLabel(BUNDLE.getString("SelectCharacterDescription.label"));
SpringLayout layout = new SpringLayout();
panel.setLayout(layout);
panel .add(label);
panel .add(field);
panel .add(ok);
panel .add(cancel);
layout.putConstraint(SpringLayout.WEST , label , 0, SpringLayout.WEST , panel );
layout.putConstraint(SpringLayout.WEST , field , 12, SpringLayout.EAST , label );
layout.putConstraint(SpringLayout.EAST , panel , 0, SpringLayout.EAST , field );
layout.putConstraint(SpringLayout.EAST , cancel, 0, SpringLayout.EAST , panel );
layout.putConstraint(SpringLayout.EAST , ok , -5, SpringLayout.WEST , cancel);
layout.putConstraint(SpringLayout.NORTH, label , 0, SpringLayout.NORTH, panel );
layout.putConstraint(SpringLayout.NORTH, field , 0, SpringLayout.NORTH, panel );
layout.putConstraint(SpringLayout.NORTH, cancel, 17, SpringLayout.SOUTH, field );
layout.putConstraint(SpringLayout.NORTH, ok , 17, SpringLayout.SOUTH, field );
layout.putConstraint(SpringLayout.SOUTH, panel, 0, SpringLayout.SOUTH, cancel);
layout.putConstraint(SpringLayout.SOUTH, panel , 0, SpringLayout.SOUTH, ok );
panel.setBorder(BorderFactory.createEmptyBorder(12, 12, 11, 11));
getContentPane().add(panel);
pack();
}
private void setInitialString (String s) {
field.setText(s.trim());
ok.setEnabled(!s.trim().isEmpty());
}
}
} | false | fastPlotViews_src_main_java_gov_nasa_arc_mct_fastplot_view_LegendEntryPopupMenuFactory.java |
722 | item.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
legendEntry.setForeground(PlotLineColorPalette.getColor(colorIndex));
manifestation.persistPlotLineSettings();
}
}); | false | fastPlotViews_src_main_java_gov_nasa_arc_mct_fastplot_view_LegendEntryPopupMenuFactory.java |
723 | item.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
settings.setThickness(thickness);
legendEntry.setLineSettings(settings);
manifestation.persistPlotLineSettings();
}
}); | false | fastPlotViews_src_main_java_gov_nasa_arc_mct_fastplot_view_LegendEntryPopupMenuFactory.java |
724 | item.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
settings.setMarker(marker);
settings.setUseCharacter(false);
legendEntry.setLineSettings(settings);
manifestation.persistPlotLineSettings();
}
}); | false | fastPlotViews_src_main_java_gov_nasa_arc_mct_fastplot_view_LegendEntryPopupMenuFactory.java |
725 | other.addActionListener( new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
final CharacterDialog dialog = new CharacterDialog();
dialog.setInitialString(settings.getCharacter());
dialog.ok.addActionListener( new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
settings.setCharacter(dialog.field.getText().trim());
settings.setUseCharacter(true);
legendEntry.setLineSettings(settings);
manifestation.persistPlotLineSettings();
}
});
dialog.setVisible(true);
}
}); | false | fastPlotViews_src_main_java_gov_nasa_arc_mct_fastplot_view_LegendEntryPopupMenuFactory.java |
726 | dialog.ok.addActionListener( new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
settings.setCharacter(dialog.field.getText().trim());
settings.setUseCharacter(true);
legendEntry.setLineSettings(settings);
manifestation.persistPlotLineSettings();
}
}); | false | fastPlotViews_src_main_java_gov_nasa_arc_mct_fastplot_view_LegendEntryPopupMenuFactory.java |
727 | spinner.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
legendEntry.setNumberRegressionPoints(Integer.parseInt(((JSpinner)e.getSource()).getValue().toString()));
}
}); | false | fastPlotViews_src_main_java_gov_nasa_arc_mct_fastplot_view_LegendEntryPopupMenuFactory.java |
728 | addPopupMenuListener(new PopupMenuListener() {
@Override
public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
// TODO Auto-generated method stub
}
@Override
public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
if (spinnerValue != Integer.parseInt(spinner.getValue().toString())) {
manifestation.persistPlotLineSettings();
}
}
@Override
public void popupMenuCanceled(PopupMenuEvent e) {
// TODO Auto-generated method stub
}
}); | false | fastPlotViews_src_main_java_gov_nasa_arc_mct_fastplot_view_LegendEntryPopupMenuFactory.java |
729 | regressionLineCheckBox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
AbstractButton abstractButton = (AbstractButton) e.getSource();
if (abstractButton.getModel().isSelected()) {
legendEntry.setHasRegressionLine(true);
} else {
legendEntry.setHasRegressionLine(false);
}
manifestation.persistPlotLineSettings();
}
}); | false | fastPlotViews_src_main_java_gov_nasa_arc_mct_fastplot_view_LegendEntryPopupMenuFactory.java |
730 | private class CharacterDialog extends JDialog {
private static final long serialVersionUID = 1644116578638815212L;
private JTextField field = new JTextField(1);
private JButton ok, cancel;
public CharacterDialog() {
super((Frame) SwingUtilities.windowForComponent(manifestation));
Frame f = (Frame) SwingUtilities.windowForComponent(manifestation);
setTitle(BUNDLE.getString("SelectCharacter.title") + " - " +
f.getTitle() + " - " +
manifestation.getInfo().getViewName());
setLocationRelativeTo((Frame) SwingUtilities.windowForComponent(manifestation));
ActionListener closer = new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
setVisible(false);
dispose();
}
};
ok = new JButton("OK");
cancel = new JButton("Cancel");
ok .addActionListener(closer);
cancel.addActionListener(closer);
final Document doc = field.getDocument();
if (doc instanceof AbstractDocument) {
AbstractDocument ad = (AbstractDocument) doc;
ad.setDocumentFilter(new DocumentFilter() {
@Override
public void insertString(FilterBypass bypass, int offset,
String str, AttributeSet attr)
throws BadLocationException {
if (doc.getLength() + str.length() < 2 && !str.trim().isEmpty()) {
super.insertString(bypass, offset, str, attr);
}
}
@Override
public void replace(FilterBypass bypass, int start,
int length, String str, AttributeSet attr)
throws BadLocationException {
if (doc.getLength() + str.length() < 2 && !str.trim().isEmpty()) {
super.replace(bypass, start, length, str, attr);
}
}
});
}
doc.addDocumentListener(new DocumentListener() {
@Override
public void changedUpdate(DocumentEvent arg0) {
ok.setEnabled(doc.getLength() == 1);
}
@Override
public void insertUpdate(DocumentEvent arg0) {
ok.setEnabled(doc.getLength() == 1);
}
@Override
public void removeUpdate(DocumentEvent arg0) {
ok.setEnabled(doc.getLength() == 1);
}
});
JPanel panel = new JPanel();
JLabel label = new JLabel(BUNDLE.getString("SelectCharacterDescription.label"));
SpringLayout layout = new SpringLayout();
panel.setLayout(layout);
panel .add(label);
panel .add(field);
panel .add(ok);
panel .add(cancel);
layout.putConstraint(SpringLayout.WEST , label , 0, SpringLayout.WEST , panel );
layout.putConstraint(SpringLayout.WEST , field , 12, SpringLayout.EAST , label );
layout.putConstraint(SpringLayout.EAST , panel , 0, SpringLayout.EAST , field );
layout.putConstraint(SpringLayout.EAST , cancel, 0, SpringLayout.EAST , panel );
layout.putConstraint(SpringLayout.EAST , ok , -5, SpringLayout.WEST , cancel);
layout.putConstraint(SpringLayout.NORTH, label , 0, SpringLayout.NORTH, panel );
layout.putConstraint(SpringLayout.NORTH, field , 0, SpringLayout.NORTH, panel );
layout.putConstraint(SpringLayout.NORTH, cancel, 17, SpringLayout.SOUTH, field );
layout.putConstraint(SpringLayout.NORTH, ok , 17, SpringLayout.SOUTH, field );
layout.putConstraint(SpringLayout.SOUTH, panel, 0, SpringLayout.SOUTH, cancel);
layout.putConstraint(SpringLayout.SOUTH, panel , 0, SpringLayout.SOUTH, ok );
panel.setBorder(BorderFactory.createEmptyBorder(12, 12, 11, 11));
getContentPane().add(panel);
pack();
}
private void setInitialString (String s) {
field.setText(s.trim());
ok.setEnabled(!s.trim().isEmpty());
}
} | false | fastPlotViews_src_main_java_gov_nasa_arc_mct_fastplot_view_LegendEntryPopupMenuFactory.java |
731 | ActionListener closer = new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
setVisible(false);
dispose();
}
}; | false | fastPlotViews_src_main_java_gov_nasa_arc_mct_fastplot_view_LegendEntryPopupMenuFactory.java |
732 | ad.setDocumentFilter(new DocumentFilter() {
@Override
public void insertString(FilterBypass bypass, int offset,
String str, AttributeSet attr)
throws BadLocationException {
if (doc.getLength() + str.length() < 2 && !str.trim().isEmpty()) {
super.insertString(bypass, offset, str, attr);
}
}
@Override
public void replace(FilterBypass bypass, int start,
int length, String str, AttributeSet attr)
throws BadLocationException {
if (doc.getLength() + str.length() < 2 && !str.trim().isEmpty()) {
super.replace(bypass, start, length, str, attr);
}
}
}); | false | fastPlotViews_src_main_java_gov_nasa_arc_mct_fastplot_view_LegendEntryPopupMenuFactory.java |
733 | doc.addDocumentListener(new DocumentListener() {
@Override
public void changedUpdate(DocumentEvent arg0) {
ok.setEnabled(doc.getLength() == 1);
}
@Override
public void insertUpdate(DocumentEvent arg0) {
ok.setEnabled(doc.getLength() == 1);
}
@Override
public void removeUpdate(DocumentEvent arg0) {
ok.setEnabled(doc.getLength() == 1);
}
}); | false | fastPlotViews_src_main_java_gov_nasa_arc_mct_fastplot_view_LegendEntryPopupMenuFactory.java |
734 | private class SolidColorIcon implements Icon {
private Color iconColor;
public SolidColorIcon (Color c) {
iconColor = c;
}
@Override
public int getIconHeight() {
return 12;
}
@Override
public int getIconWidth() {
return 48;
}
@Override
public void paintIcon(Component arg0, Graphics g, int x,
int y) {
g.setColor(iconColor);
g.fillRect(x, y, getIconWidth(), getIconHeight() - 1);
g.setColor(iconColor.darker());
g.drawRect(x, y, getIconWidth(), getIconHeight() - 1);
}
} | false | fastPlotViews_src_main_java_gov_nasa_arc_mct_fastplot_view_LegendEntryPopupMenuFactory.java |
735 | class NumericPlainDocument extends PlainDocument {
private static final long serialVersionUID = 1L;
private final static Logger logger = LoggerFactory.getLogger(NumericPlainDocument.class);
public NumericPlainDocument() {
setFormat(null);
}
public void setFormat(DecimalFormat fmt) {
this.format = fmt != null ? fmt : (DecimalFormat) defaultFormat.clone();
decimalSeparator = format.getDecimalFormatSymbols().getDecimalSeparator();
groupingSeparator = format.getDecimalFormatSymbols().getGroupingSeparator();
positivePrefix = format.getPositivePrefix();
positivePrefixLen = positivePrefix.length();
negativePrefix = format.getNegativePrefix();
negativePrefixLen = negativePrefix.length();
positiveSuffix = format.getPositiveSuffix();
positiveSuffixLen = positiveSuffix.length();
negativeSuffix = format.getNegativeSuffix();
negativeSuffixLen = negativeSuffix.length();
}
public DecimalFormat getFormat() {
return format;
}
public Number getNumberValue() throws ParseException {
try {
String content = getText(0, getLength());
parsePos.setIndex(0);
Number result = format.parse(content, parsePos);
if (parsePos.getIndex() != getLength()) {
throw new ParseException("Not a valid number: " + content, 0);
}
return result;
} catch (BadLocationException e) {
throw new ParseException("Not a valid number", 0);
}
}
public Long getLongValue() throws ParseException {
Number result = getNumberValue();
if ((result instanceof Long) == false) {
throw new ParseException("Not a valid long", 0);
}
return (Long) result;
}
public Double getDoubleValue() throws ParseException {
Number result = getNumberValue();
if ((result instanceof Long) == false
&& (result instanceof Double) == false) {
throw new ParseException("Not a valid double", 0);
}
if (result instanceof Long) {
result = Double.valueOf(result.doubleValue());
}
return (Double) result;
}
public void insertString(int offset, String str, AttributeSet a)
throws BadLocationException {
if (str == null || str.length() == 0) {
return;
}
Content content = getContent();
int length = content.length();
int originalLength = length;
parsePos.setIndex(0);
// Create the result of inserting the new data,
// but ignore the trailing newline
String targetString = content.getString(0, offset) + str
+ content.getString(offset, length - offset - 1);
// Parse the input string and check for errors
do {
boolean gotPositive = targetString.startsWith(positivePrefix);
boolean gotNegative = targetString.startsWith(negativePrefix);
length = targetString.length();
// If we have a valid prefix, the parse fails if the
// suffix is not present and the error is reported
// at index 0. So, we need to add the appropriate
// suffix if it is not present at this point.
if (gotPositive == true || gotNegative == true) {
int prefixLength;
if (gotPositive == true && gotNegative == true) {
// This happens if one is the leading part of
// the other - e.g. if one is "(" and the other "(("
if (positivePrefixLen > negativePrefixLen) {
gotNegative = false;
} else {
gotPositive = false;
}
}
if (gotPositive == true) {
prefixLength = positivePrefixLen;
} else {
// Must have the negative prefix
prefixLength = negativePrefixLen;
}
// If the string consists of the prefix alone,
// do nothing, or the result won't parse.
if (length == prefixLength) {
break;
}
}
try {
format.parse(targetString, parsePos);
} catch (NumberFormatException e) {
logger.error("Number format exception when parsing \n" +
" targetString = " + targetString + "\n" +
" parsePos = " + parsePos.toString());
}
int endIndex = parsePos.getIndex();
if (endIndex == length) {
break; // Number is acceptable
}
// Parse ended early
// Since incomplete numbers don't always parse, try
// to work out what went wrong.
// First check for an incomplete positive prefix
if (positivePrefixLen > 0 && endIndex < positivePrefixLen
&& length <= positivePrefixLen
&& targetString.regionMatches(0, positivePrefix, 0, length)) {
break; // Accept for now
}
// Next check for an incomplete negative prefix
if (negativePrefixLen > 0 && endIndex < negativePrefixLen
&& length <= negativePrefixLen
&& targetString.regionMatches(0, negativePrefix, 0, length)) {
break; // Accept for now
}
// Allow a number that ends with the group
// or decimal separator, if these are in use
char lastChar = targetString.charAt(originalLength - 1);
int decimalIndex = targetString.indexOf(decimalSeparator);
if (format.isGroupingUsed() && lastChar == groupingSeparator
&& decimalIndex == -1) {
// Allow a "," but only in integer part
break;
}
if (format.isParseIntegerOnly() == false
&& lastChar == decimalSeparator
&& decimalIndex == originalLength - 1) {
// Allow a ".", but only one
break;
}
// No more corrections to make: must be an error
if (errorListener != null) {
errorListener.insertFailed(this, offset, str, a);
}
return;
} while (false);
// Finally, add to the model
super.insertString(offset, str, a);
}
public void addInsertErrorListener(InsertErrorListener l) {
if (errorListener == null) {
errorListener = l;
return;
}
throw new IllegalArgumentException("InsertErrorListener already registered");
}
public void removeInsertErrorListener(InsertErrorListener l) {
if (errorListener == l) {
errorListener = null;
}
}
InsertErrorListener getInsertErrorListener() {
return errorListener;
}
public interface InsertErrorListener {
public abstract void insertFailed(
NumericPlainDocument doc, int offset, String str, AttributeSet a);
}
protected InsertErrorListener errorListener;
protected DecimalFormat format;
protected char decimalSeparator;
protected char groupingSeparator;
protected String positivePrefix;
protected String negativePrefix;
protected int positivePrefixLen;
protected int negativePrefixLen;
protected String positiveSuffix;
protected String negativeSuffix;
protected int positiveSuffixLen;
protected int negativeSuffixLen;
protected ParsePosition parsePos = new ParsePosition(0);
protected static DecimalFormat defaultFormat = new DecimalFormat();
} | false | fastPlotViews_src_main_java_gov_nasa_arc_mct_fastplot_view_NumericTextField.java |
736 | public interface InsertErrorListener {
public abstract void insertFailed(
NumericPlainDocument doc, int offset, String str, AttributeSet a);
} | false | fastPlotViews_src_main_java_gov_nasa_arc_mct_fastplot_view_NumericTextField.java |
737 | public class NumericTextField extends JTextField implements NumericPlainDocument.InsertErrorListener {
private static final long serialVersionUID = 1L;
public NumericTextField() {
this(null, 0, null);
}
public NumericTextField(String text, int columns, DecimalFormat format) {
super(null, text, columns);
setHorizontalAlignment(JTextField.RIGHT);
NumericPlainDocument numericDoc = (NumericPlainDocument) getDocument();
if (format != null) {
numericDoc.setFormat(format);
}
numericDoc.addInsertErrorListener(this);
}
public NumericTextField(int columns, DecimalFormat format) {
this(null, columns, format);
}
public NumericTextField(String text) {
this(text, 0, null);
}
public NumericTextField(String text, int columns) {
this(text, columns, null);
}
public void setFormat(DecimalFormat format) {
((NumericPlainDocument) getDocument()).setFormat(format);
}
public DecimalFormat getFormat() {
return ((NumericPlainDocument) getDocument()).getFormat();
}
public void formatChanged() {
// Notify change of format attributes.
setFormat(getFormat());
}
// Methods to get the field value
public Long getLongValue() throws ParseException {
return ((NumericPlainDocument) getDocument()).getLongValue();
}
public Double getDoubleValue() throws ParseException {
return ((NumericPlainDocument) getDocument()).getDoubleValue();
}
public Number getNumberValue() throws ParseException {
return ((NumericPlainDocument) getDocument()).getNumberValue();
}
// Methods to install numeric values
public void setValue(Number number) {
setText(getFormat().format(number));
}
public void setValue(long l) {
setText(getFormat().format(l));
}
public void setValue(double d) {
setText(getFormat().format(d));
}
public void normalize() throws ParseException {
// format the value according to the format string
setText(getFormat().format(getNumberValue()));
}
// Override to handle insertion error
public void insertFailed(NumericPlainDocument doc, int offset, String str,
AttributeSet a) {
}
// Method to create default model
protected Document createDefaultModel() {
return new NumericPlainDocument();
}
} | false | fastPlotViews_src_main_java_gov_nasa_arc_mct_fastplot_view_NumericTextField.java |
738 | public class PinSupport {
private int pinCount;
/**
* Called whenever the overall pin state changes.
* The default implementation does nothing.
* @param pinned true if the object is pinned
*/
protected void informPinned(boolean pinned) {
}
/**
* Returns true if any of the pins are pinned.
* @return true if the object is pinned
*/
public boolean isPinned() {
return pinCount > 0;
}
/**
* Creates a new pin.
* @return new pin
*/
public Pinnable createPin() {
return new Pin();
}
private class Pin implements Pinnable {
private boolean pinned;
public void setPinned(boolean pinned) {
if(pinned && !this.pinned) {
pinCount++;
if(pinCount == 1) {
informPinned(true);
}
} else if(!pinned && this.pinned) {
pinCount--;
if(pinCount == 0) {
informPinned(false);
}
}
this.pinned = pinned;
assert pinCount >= 0;
}
public boolean isPinned() {
return pinned;
}
@Override
protected void finalize() {
setPinned(false);
}
}
} | false | fastPlotViews_src_main_java_gov_nasa_arc_mct_fastplot_view_PinSupport.java |
739 | private class Pin implements Pinnable {
private boolean pinned;
public void setPinned(boolean pinned) {
if(pinned && !this.pinned) {
pinCount++;
if(pinCount == 1) {
informPinned(true);
}
} else if(!pinned && this.pinned) {
pinCount--;
if(pinCount == 0) {
informPinned(false);
}
}
this.pinned = pinned;
assert pinCount >= 0;
}
public boolean isPinned() {
return pinned;
}
@Override
protected void finalize() {
setPinned(false);
}
} | false | fastPlotViews_src_main_java_gov_nasa_arc_mct_fastplot_view_PinSupport.java |
740 | public interface Pinnable {
/**
* Sets whether or not this object is pinned.
* @param pinned true if this is pinned
*/
public void setPinned(boolean pinned);
/**
* Returns true if this is pinned.
* @return true if this is pinned
*/
public boolean isPinned();
} | false | fastPlotViews_src_main_java_gov_nasa_arc_mct_fastplot_view_Pinnable.java |
741 | public class PlotControlsLayout implements LayoutManager2 {
/**
* This scroll pane class provides a convenient way to access the resizeable components
* that reside in this scroll pane, eliminating a search.
*/
@SuppressWarnings("serial")
public class ResizersScrollPane extends JScrollPane {
private JComponent[] resizers;
public ResizersScrollPane(JComponent component, JComponent... resizerWidget) {
super(component);
int numResizers = resizerWidget.length;
resizers = new JComponent[numResizers];
for (int k = 0; k < numResizers; k++) {
resizers[k] = resizerWidget[k];
}
}
public JComponent[] getResizers() {
return resizers;
}
}
private static final int DEFAULT_PADDING = 0;
public static final String MIDDLE = "Middle";
public static final String LOWER = "Lower";
private int minWidth = 0;
private int minHeight = 0;
private boolean sizeUnknown = true;
private int preferredWidth;
private int preferredHeight;
/*
* The padding between the middle panel and the lower panel
*/
private int innerPadding = 0;
private Component middleComponent;
private Component lowerComponent;
public PlotControlsLayout() {
this(DEFAULT_PADDING);
}
public PlotControlsLayout(int padding) {
innerPadding = padding;
}
/*
* LayoutManager2
* NOTE: there is another method with same name in LayoutManager
*/
@Override
public void addLayoutComponent(final Component comp, Object constraints) {
if (constraints instanceof String) {
String name = (String) constraints;
if (MIDDLE.equals(name)) {
middleComponent = comp;
if (comp instanceof ResizersScrollPane) {
final JComponent parent = (JComponent) comp.getParent();
JComponent[] children = ((ResizersScrollPane) comp).getResizers();
for (JComponent child : children) {
if (child.getComponentListeners().length == 0) {
child.addComponentListener(new ComponentListener() {
@Override
public void componentResized(ComponentEvent e) {
parent.revalidate();
}
@Override
public void componentShown(ComponentEvent e) {
}
@Override
public void componentMoved(ComponentEvent e) {
}
@Override
public void componentHidden(ComponentEvent e) {
}
});
}
}
}
} else
if (LOWER.equals(name)) {
lowerComponent = comp;
} else {
throw new IllegalArgumentException("Cannot use unknown constraint in layout: " + name);
}
}
}
/* LayoutManager2 */
@Override
public float getLayoutAlignmentX(Container target) {
return 0.5f;
}
/* LayoutManager2 */
@Override
public float getLayoutAlignmentY(Container target) {
return 0.5f;
}
/* LayoutManager2 */
@Override
public void invalidateLayout(Container target) {
}
/* LayoutManager2 */
@Override
public Dimension maximumLayoutSize(Container target) {
if (sizeUnknown) {
setSizes(target);
}
return new Dimension(preferredWidth, preferredHeight);
}
/*
* LayoutManager
* NOTE: another method with same name in LayoutManager2
*/
@Override
public void addLayoutComponent(String name, Component comp) {
}
/* LayoutManager */
/*
* This is called when the panel is first displayed, and every time its size changes.
* Note: You can't assume preferredLayoutSize or minimumLayoutSize will be called.
*/
@Override
public void layoutContainer(Container parent) {
if (sizeUnknown) {
setSizes(parent);
}
if (middleComponent != null && lowerComponent != null ) {
doLayout(parent, middleComponent, lowerComponent);
} else
if (middleComponent != null) {
middleComponent.setBounds(0, 0, parent.getSize().width, middleComponent.getPreferredSize().height);
} else
if (lowerComponent != null) {
lowerComponent.setBounds(0, 0, parent.getSize().width, lowerComponent.getPreferredSize().height);
}
}
private void doLayout(Container parent, Component middleComp, Component lowerComp) {
Dimension parentDim = parent.getSize();
Dimension middleDim = middleComp.getPreferredSize();
Dimension lowerDim = lowerComp.getPreferredSize();
// In the following, the middle component is a scroll pane and the lower component is a panel.
// a) The widths of both the scroll pane and the panel are expanded to the width of the parent
// b) Maintain a buffer (INNER_PADDING) between the scroll pane and the panel
// c) The panel is positioned at the bottom of the parent, and is allowed its preferred height
// d) The scroll pane shrinks to fit the remaining space after the panel and buffer are handled
// Does the parent have enough space for both components ?
if (middleDim.height + lowerDim.height + innerPadding < parentDim.height) {
// If so, position the scroll pane at the top of the parent
middleComp.setBounds(0, 0, parentDim.width, middleDim.height);
lowerComp.setBounds(0, middleDim.height + innerPadding - 1, parentDim.width, lowerDim.height);
} else {
// If not, shrink the height of the scroll pane, and ensure the panel is completely visible
// as long as possible while parent shrinks.
int overlapY = middleDim.height + lowerDim.height + innerPadding - parentDim.height;
middleComp.setBounds(0, 0, parentDim.width, middleDim.height - overlapY);
lowerComp.setBounds(0, middleDim.height + innerPadding - overlapY - 1, parentDim.width, lowerDim.height);
parent.setComponentZOrder(lowerComp, 0);
}
}
/* LayoutManager */
@Override
public Dimension minimumLayoutSize(Container parent) {
if (sizeUnknown) {
setSizes(parent);
}
Dimension dim = new Dimension(0, 0);
// Always add the container's insets
Insets insets = parent.getInsets();
dim.width = minWidth + insets.left + insets.right;
dim.height = minHeight + insets.top + insets.bottom;
return dim;
}
/* LayoutManager */
@Override
public Dimension preferredLayoutSize(Container parent) {
if (sizeUnknown) {
setSizes(parent);
}
Dimension dim = new Dimension(0, 0);
// Always add the container's insets
Insets insets = parent.getInsets();
dim.width = preferredWidth + insets.left + insets.right;
dim.height = preferredHeight + insets.top + insets.bottom;
return dim;
}
private void setSizes(Container parent) {
int nComps = parent.getComponentCount();
// Reset preferred/minimum width and height.
preferredWidth = 0;
preferredHeight = 0;
minWidth = 0;
minHeight = 0;
for (int i = 0; i < nComps; i++) {
Component comp = parent.getComponent(i);
if (comp.isVisible()) {
Dimension prefSize = comp.getPreferredSize();
preferredWidth = (prefSize.width > preferredWidth) ? prefSize.width : preferredWidth;
preferredHeight += prefSize.height;
minWidth = Math.max(comp.getMinimumSize().width, minWidth);
minHeight += comp.getMinimumSize().height;
}
}
sizeUnknown = false;
}
/* LayoutManager */
@Override
public void removeLayoutComponent(Component comp) {
if (comp == middleComponent) {
middleComponent = null;
} else
if (comp == lowerComponent) {
lowerComponent = null;
}
}
void resetSizeFlag() {
sizeUnknown = true;
}
} | false | fastPlotViews_src_main_java_gov_nasa_arc_mct_fastplot_view_PlotControlsLayout.java |
742 | child.addComponentListener(new ComponentListener() {
@Override
public void componentResized(ComponentEvent e) {
parent.revalidate();
}
@Override
public void componentShown(ComponentEvent e) {
}
@Override
public void componentMoved(ComponentEvent e) {
}
@Override
public void componentHidden(ComponentEvent e) {
}
}); | false | fastPlotViews_src_main_java_gov_nasa_arc_mct_fastplot_view_PlotControlsLayout.java |
743 | @SuppressWarnings("serial")
public class ResizersScrollPane extends JScrollPane {
private JComponent[] resizers;
public ResizersScrollPane(JComponent component, JComponent... resizerWidget) {
super(component);
int numResizers = resizerWidget.length;
resizers = new JComponent[numResizers];
for (int k = 0; k < numResizers; k++) {
resizers[k] = resizerWidget[k];
}
}
public JComponent[] getResizers() {
return resizers;
}
} | false | fastPlotViews_src_main_java_gov_nasa_arc_mct_fastplot_view_PlotControlsLayout.java |
744 | public class PlotDataAssigner {
private PlotViewManifestation plotViewManifestation;
final AtomicReference<Collection<FeedProvider>> feedProvidersRef;
Collection<Collection<FeedProvider>> feedsToPlot;
Collection<FeedProvider> predictiveFeeds;
PlotDataAssigner(PlotViewManifestation supportedPlotViewManifestation) {
plotViewManifestation = supportedPlotViewManifestation;
feedProvidersRef = new AtomicReference<Collection<FeedProvider>>(new ArrayList<FeedProvider>());
feedsToPlot = new ArrayList<Collection<FeedProvider>>();
predictiveFeeds = new ArrayList<FeedProvider>();
}
Collection<FeedProvider> getVisibleFeedProviders() {
if (!hasFeeds()) {
updateFeedProviders();
}
return feedProvidersRef.get();
}
Collection<FeedProvider> getPredictiveFeedProviders() {
if (!hasFeeds()) {
updateFeedProviders();
}
return predictiveFeeds;
}
void informFeedProvidersHaveChanged() {
updateFeedProviders();
}
int returnNumberOfSubPlots() {
return feedsToPlot.size();
}
private void updateFeedProviders() {
AbstractComponent[][] matrix = PlotViewPolicy.getPlotComponents(
plotViewManifestation.getManifestedComponent(),
useOrdinalPosition());
updateFeedProviders(matrix);
}
private boolean useOrdinalPosition() {
String groupByAsString = plotViewManifestation.getViewProperties().getProperty(PlotConstants.GROUP_BY_ORDINAL_POSITION, String.class);
return (groupByAsString == null || groupByAsString.isEmpty()) ? true : Boolean.valueOf(groupByAsString);
}
private void updateFeedProviders(AbstractComponent[][] matrix) {
ArrayList<FeedProvider> feedProviders = new ArrayList<FeedProvider>();
feedsToPlot.clear();
predictiveFeeds.clear();
for (AbstractComponent[] row : matrix) {
Collection<FeedProvider> feedsForThisLevel = new ArrayList<FeedProvider>(); //this should be LMIT
int numberOfItemsOnSubPlot = 0;
for (AbstractComponent component : row) {
if (numberOfItemsOnSubPlot < PlotConstants.MAX_NUMBER_OF_DATA_ITEMS_ON_A_PLOT) {
FeedProvider fp = plotViewManifestation.getFeedProvider(component);
if (fp != null) {
if(fp.getFeedType() != FeedType.STRING){ //only add to feed providers if not a string feed
feedProviders.add(fp);
if (fp.isPrediction()) {
predictiveFeeds.add(fp);
}
feedsForThisLevel.add(fp);
}
}
numberOfItemsOnSubPlot++;
}
}
feedsToPlot.add(feedsForThisLevel);
}
feedProviders.trimToSize();
feedProvidersRef.set(feedProviders);
}
/**
* Return true if the plot has feeds, false otherwise.
* @return
*/
boolean hasFeeds() {
return !feedProvidersRef.get().isEmpty();
}
void assignFeedsToSubPlots() {
assert feedsToPlot !=null : "Feeds to plot must be defined";
// Add feeds to the plot.
int subPlotNumber = 0;
for (Collection<FeedProvider> feedsForSubPlot: feedsToPlot) {
assert feedsForSubPlot!=null;
int numberOfItemsOnSubPlot = 0;
for(FeedProvider fp: feedsForSubPlot) {
if (numberOfItemsOnSubPlot < PlotConstants.MAX_NUMBER_OF_DATA_ITEMS_ON_A_PLOT) {
plotViewManifestation.thePlot.addDataSet(subPlotNumber, fp.getSubscriptionId(), fp.getLegendText());
numberOfItemsOnSubPlot++;
}
}
subPlotNumber++;
}
}
} | false | fastPlotViews_src_main_java_gov_nasa_arc_mct_fastplot_view_PlotDataAssigner.java |
745 | public class PlotDataFeedUpdateHandler {
private final static Logger logger = LoggerFactory
.getLogger(PlotDataFeedUpdateHandler.class);
private PlotViewManifestation plotViewManifestation;
private static final RenderingInfo DEFAULT_RI = new RenderingInfo(null, Color.WHITE, "0", Color.WHITE, false);
PlotDataFeedUpdateHandler(
PlotViewManifestation supportedPlotViewManifestation) {
plotViewManifestation = supportedPlotViewManifestation;
}
void synchronizeTime(Map<String, List<Map<String, String>>> data,
long syncTime) {
GregorianCalendar calendar = new GregorianCalendar();
calendar.setTimeInMillis(syncTime);
plotViewManifestation.thePlot.showTimeSyncLine(calendar);
updateFromFeeds(data, true, true, false);
}
void updateFromFeed(Map<String, List<Map<String, String>>> data, boolean predictionOnly) {
plotViewManifestation.thePlot.informUpdateFromFeedEventStarted();
// Receiving any data from the feed informs us that any sync lines
// should be
// removed.
// Check if we cached updates while the updateFromFeed was previously
// locked.
updateFromFeeds(data, false, true, predictionOnly);
plotViewManifestation.thePlot.refreshDisplay();
// Request that the plot updates its display with the new feed data.
if (plotViewManifestation.controlPanel != null
&& plotViewManifestation.controlPanel.isShowing()) {
plotViewManifestation.controlPanel.refreshDisplay();
}
plotViewManifestation.thePlot.informUpdateFromFeedEventCompleted();
}
public void processData(Map<String, List<Map<String, String>>> data) {
if (logger.isDebugEnabled()) {
logger.debug("\n Recived new slice {}", printDataOnSlice(data));
}
boolean currentCompressionState = plotViewManifestation.thePlot.isCompresionEnabled();
try {
plotViewManifestation.thePlot.setCompressionEnabled(false);
updateFromFeeds(data, false, false, false);
} finally {
plotViewManifestation.thePlot.setCompressionEnabled(currentCompressionState);
}
}
public void startDataRequest() {
plotViewManifestation.thePlot.informUpdateDataEventStarted();
plotViewManifestation.thePlot.refreshDisplay();
}
public void endDataRequest() {
closeOutProcessData();
}
private void closeOutProcessData() {
if (plotViewManifestation.controlPanel != null
&& plotViewManifestation.controlPanel.isShowing()) {
plotViewManifestation.controlPanel.refreshDisplay();
}
// unlock the plot's update events.
plotViewManifestation.thePlot.informUpdateDataEventCompleted();
plotViewManifestation.thePlot.refreshDisplay();
}
/**
* Unwrap the data from the feed service.
*
* @param feedIds
* the set of feed IDs
* @param data
* the data
*/
void updateFromFeeds(Map<String, List<Map<String, String>>> data,
boolean legendOnly, boolean updateLegend, boolean predictionOnly) {
if (data != null) {
Map<String, SortedMap<Long, Double>> dataForPlot = new HashMap<String, SortedMap<Long,Double>>();
// Iterate over the feeds (each is a plot line on the chart)
Collection<FeedProvider> feeds = plotViewManifestation
.getVisibleFeedProviders();
for (FeedProvider provider : feeds) {
if (provider.getFeedType() != FeedType.STRING) {
String feedId = provider.getSubscriptionId();
List<Map<String, String>> dataForThisFeed = data.get(feedId);
// This prevents "live" data (from the current time, not the maximum valid time) from predictive feeds from
// showing up in the plot. This prevents a bug where live data arrives in the middle of a historical data request, and
// the plot thinks the next historical slice is redundant and ignores it (since it overlaps with the live data).
boolean allowPlotting = predictionOnly == provider.isPrediction() || !updateLegend;
if (dataForThisFeed != null && plotViewManifestation.thePlot.isKnownDataSet(feedId) && allowPlotting) {
SortedMap<Long, Double> dataForPlotThisFeed = dataForPlot.get(feedId);
if(dataForPlotThisFeed == null) {
dataForPlotThisFeed = new TreeMap<Long, Double>();
dataForPlot.put(feedId, dataForPlotThisFeed);
}
RenderingInfo lastRI = DEFAULT_RI;
boolean haveLegendInfo = false;
// Loop over each point that needs to be plotted for this
// feed.
for (Map<String, String> pointsData : dataForThisFeed) {
RenderingInfo ri = provider
.getRenderingInfo(pointsData);
assert pointsData != null : "PointsData is Null";
String timeAsString = pointsData
.get(FeedProvider.NORMALIZED_TIME_KEY);
String valueAsString = ri.getValueText();
boolean isPlottable = ri.isPlottable();
// Robust to time or value keys not being present.
if (timeAsString != null && valueAsString != null) {
try {
long milliSecondsEpoch = Long
.parseLong(timeAsString);
if (!isPlottable) {
valueAsString = "";
}
lastRI = ri;
haveLegendInfo = true;
if (!plotViewManifestation.thePlot
.isKnownDataSet(feedId)) {
plotViewManifestation.thePlot.addDataSet(
feedId, provider.getLegendText());
}
if (!legendOnly) {
double value;
if(isPlottable) {
value = Double.parseDouble(valueAsString);
} else {
value = Double.NaN;
}
dataForPlotThisFeed.put(milliSecondsEpoch, value);
}
} catch (NumberFormatException e) {
logger
.error(
"Number format exception converting string to double while processing the data feed entry {}, {}",
timeAsString, valueAsString);
}
} else {
logger
.error(
"Either time, value, or isValid entry was not defined. {}, {}",
timeAsString, valueAsString);
}
}
if (haveLegendInfo && updateLegend) {
plotViewManifestation.thePlot.updateLegend(feedId, lastRI);
}
}
}
}
plotViewManifestation.thePlot.addData(dataForPlot);
} else {
logger.debug("Data was null");
}
}
private String printDataOnSlice(Map<String, List<Map<String, String>>> data) {
long earliestTime = Long.MAX_VALUE;
long latestTime = -Long.MAX_VALUE;
int numberDataPoints = 0;
for (String feedId : data.keySet()) {
List<Map<String, String>> dataForThisFeed = data.get(feedId);
if (dataForThisFeed != null) {
for (Map<String, String> pointsData : dataForThisFeed) {
assert pointsData != null : "PointsData is Null";
String timeAsString = pointsData
.get(FeedProvider.NORMALIZED_TIME_KEY);
if (timeAsString != null) {
try {
numberDataPoints++;
long milliSecondsEpoch = Long
.parseLong(timeAsString);
if (milliSecondsEpoch > latestTime) {
latestTime = milliSecondsEpoch;
}
if (milliSecondsEpoch < earliestTime) {
earliestTime = milliSecondsEpoch;
}
assert latestTime >= earliestTime : "latest < earliest!";
} catch (NumberFormatException e) {
logger
.error(
"Number format exception converting string to double while processing the data feed entry {}",
timeAsString);
}
} else {
logger
.error(
"Either time, value, or isValid entry was not defined. {}",
timeAsString);
}
}
}
}
if (numberDataPoints > 0) {
return "Slice: "
+ numberDataPoints
+ " [ "
+ PlotSettingsControlPanel.CalendarDump
.dumpMillis(earliestTime)
+ " .. "
+ PlotSettingsControlPanel.CalendarDump
.dumpMillis(latestTime) + " ]";
} else {
return "Slice: " + numberDataPoints + " [ .. ]";
}
}
} | false | fastPlotViews_src_main_java_gov_nasa_arc_mct_fastplot_view_PlotDataFeedUpdateHandler.java |
746 | public class PlotPersistanceHandler {
private final static Logger logger = LoggerFactory.getLogger(PlotPersistanceHandler.class);
private PlotViewManifestation plotViewManifestation;
PlotPersistanceHandler(PlotViewManifestation supportedPlotViewManifestation) {
plotViewManifestation = supportedPlotViewManifestation;
}
/**
* Load the settings for the manifestation from persistence.
* @return
*/
PlotSettings loadPlotSettingsFromPersistance() {
PlotSettings settings = new PlotSettings();
try {
settings.timeAxisSetting = Enum.valueOf(AxisOrientationSetting.class, plotViewManifestation.getViewProperties().getProperty(PlotConstants.TIME_AXIS_SETTING, String.class).trim().toUpperCase());
} catch (Exception e) {
// No persisted settings for this plot.
return settings;
}
String pinTimeAxisAsString = plotViewManifestation.getViewProperties().getProperty(PlotConstants.PIN_TIME_AXIS, String.class);
try {
settings.xAxisMaximumLocation = Enum.valueOf(XAxisMaximumLocationSetting.class, plotViewManifestation.getViewProperties().getProperty(PlotConstants.X_AXIS_MAXIMUM_LOCATION_SETTING, String.class).trim().toUpperCase());
settings.yAxisMaximumLocation = Enum.valueOf(YAxisMaximumLocationSetting.class, plotViewManifestation.getViewProperties().getProperty(PlotConstants.Y_AXIS_MAXIMUM_LOCATION_SETTING, String.class).trim().toUpperCase());
String timeAxisSubsequent = plotViewManifestation.getViewProperties().getProperty(PlotConstants.TIME_AXIS_SUBSEQUENT_SETTING, String.class).trim().toUpperCase();
// Support the old FIXED mode from the old plots
if("FIXED".equals(timeAxisSubsequent)) {
settings.timeAxisSubsequent = TimeAxisSubsequentBoundsSetting.JUMP;
pinTimeAxisAsString = "true";
} else {
settings.timeAxisSubsequent = Enum.valueOf(TimeAxisSubsequentBoundsSetting.class, timeAxisSubsequent);
}
settings.nonTimeAxisSubsequentMinSetting = Enum.valueOf(NonTimeAxisSubsequentBoundsSetting.class, plotViewManifestation.getViewProperties().getProperty(PlotConstants.NON_TIME_AXIS_SUBSEQUENT_MIN_SETTING, String.class).trim().toUpperCase());
settings.nonTimeAxisSubsequentMaxSetting = Enum.valueOf(NonTimeAxisSubsequentBoundsSetting.class, plotViewManifestation.getViewProperties().getProperty(PlotConstants.NON_TIME_AXIS_SUBSEQUENT_MAX_SETTING, String.class).trim().toUpperCase());
settings.plotLineDraw = new PlotLineDrawingFlags(
Boolean.parseBoolean(plotViewManifestation.getViewProperties().getProperty(PlotConstants.DRAW_LINES, String.class)),
Boolean.parseBoolean(plotViewManifestation.getViewProperties().getProperty(PlotConstants.DRAW_MARKERS, String.class))
);
settings.plotLineConnectionType = Enum.valueOf(PlotLineConnectionType.class, plotViewManifestation.getViewProperties().getProperty(PlotConstants.CONNECTION_TYPE, String.class).trim().toUpperCase());
} catch (Exception e) {
logger.error("Problem reading plot settings back from persistence. Continuing with default settings.");
}
try {
String maxTimeAsString = plotViewManifestation.getViewProperties().getProperty(PlotConstants.TIME_MAX, String.class);
String minTimeAsString = plotViewManifestation.getViewProperties().getProperty(PlotConstants.TIME_MIN, String.class);
String maxNonTimeAsString = plotViewManifestation.getViewProperties().getProperty(PlotConstants.NON_TIME_MAX, String.class);
String minNonTimeAsString = plotViewManifestation.getViewProperties().getProperty(PlotConstants.NON_TIME_MIN, String.class);
String timePaddingAsString = plotViewManifestation.getViewProperties().getProperty(PlotConstants.TIME_PADDING, String.class);
String nonTimeMinPaddingAsString = plotViewManifestation.getViewProperties().getProperty(PlotConstants.NON_TIME_MIN_PADDING, String.class);
String nonTimeMaxPaddingAsString = plotViewManifestation.getViewProperties().getProperty(PlotConstants.NON_TIME_MAX_PADDING, String.class);
String groupByOrdinalPositionAsString = plotViewManifestation.getViewProperties().getProperty(PlotConstants.GROUP_BY_ORDINAL_POSITION, String.class);
settings.maxTime = Long.parseLong(maxTimeAsString.trim());
settings.minTime = Long.parseLong(minTimeAsString.trim());
settings.maxNonTime = Double.parseDouble(maxNonTimeAsString.trim());
settings.minNonTime = Double.parseDouble(minNonTimeAsString.trim());
settings.timePadding = Double.parseDouble(timePaddingAsString.trim());
settings.nonTimeMaxPadding = Double.parseDouble(nonTimeMaxPaddingAsString.trim());
settings.nonTimeMinPadding = Double.parseDouble(nonTimeMinPaddingAsString.trim());
if (groupByOrdinalPositionAsString != null && !groupByOrdinalPositionAsString.isEmpty()) {
settings.ordinalPositionForStackedPlots = Boolean.parseBoolean(groupByOrdinalPositionAsString);
}
if (pinTimeAxisAsString != null && !pinTimeAxisAsString.isEmpty()) {
settings.pinTimeAxis = Boolean.parseBoolean(pinTimeAxisAsString);
}
} catch (NumberFormatException nfe) {
logger.error("NumberFormatException: " + nfe.getMessage());
}
return settings;
}
/**
* Persist the plots settings.
* @param timeAxisSetting
* @param xAxisMaximumLocation
* @param yAxisMaximumLocation
* @param timeAxisSubsequentSetting
* @param nonTimeAxisSubsequentMinSetting
* @param nonTimeAxisSubsequentMaxSetting
* @param nonTimeMax
* @param nonTimeMin
* @param minTime
* @param maxTime
* @param timePadding
* @param nonTimeMaxPadding
* @param nonTimeMinPadding
* @param plotLineConnectionType
* @param plotLineDraw
*/
void persistPlotSettings(AxisOrientationSetting timeAxisSetting,
XAxisMaximumLocationSetting xAxisMaximumLocation,
YAxisMaximumLocationSetting yAxisMaximumLocation,
TimeAxisSubsequentBoundsSetting timeAxisSubsequentSetting,
NonTimeAxisSubsequentBoundsSetting nonTimeAxisSubsequentMinSetting,
NonTimeAxisSubsequentBoundsSetting nonTimeAxisSubsequentMaxSetting,
double nonTimeMax, double nonTimeMin, GregorianCalendar minTime,
GregorianCalendar maxTime,
Double timePadding,
Double nonTimeMaxPadding,
Double nonTimeMinPadding,
boolean groupByOrdinalPosition,
boolean timeAxisPinned,
PlotLineDrawingFlags plotLineDraw,
PlotLineConnectionType plotLineConnectionType) {
ExtendedProperties viewProperties = plotViewManifestation.getViewProperties();
viewProperties.setProperty(PlotConstants.TIME_AXIS_SETTING, "" + timeAxisSetting);
viewProperties.setProperty(PlotConstants.X_AXIS_MAXIMUM_LOCATION_SETTING, "" + xAxisMaximumLocation);
viewProperties.setProperty(PlotConstants.Y_AXIS_MAXIMUM_LOCATION_SETTING, "" + yAxisMaximumLocation);
viewProperties.setProperty(PlotConstants.TIME_AXIS_SUBSEQUENT_SETTING, "" + timeAxisSubsequentSetting);
viewProperties.setProperty(PlotConstants.NON_TIME_AXIS_SUBSEQUENT_MIN_SETTING, "" + nonTimeAxisSubsequentMinSetting);
viewProperties.setProperty(PlotConstants.NON_TIME_AXIS_SUBSEQUENT_MAX_SETTING, "" + nonTimeAxisSubsequentMaxSetting);
viewProperties.setProperty(PlotConstants.NON_TIME_MAX, "" + nonTimeMax);
viewProperties.setProperty(PlotConstants.NON_TIME_MIN, "" + nonTimeMin);
viewProperties.setProperty(PlotConstants.TIME_MIN, "" + minTime.getTimeInMillis());
viewProperties.setProperty(PlotConstants.TIME_MAX, "" + maxTime.getTimeInMillis());
viewProperties.setProperty(PlotConstants.TIME_PADDING, "" + timePadding);
viewProperties.setProperty(PlotConstants.NON_TIME_MAX_PADDING, "" + nonTimeMaxPadding);
viewProperties.setProperty(PlotConstants.NON_TIME_MIN_PADDING, "" + nonTimeMinPadding);
viewProperties.setProperty(PlotConstants.GROUP_BY_ORDINAL_POSITION, Boolean.toString(groupByOrdinalPosition));
viewProperties.setProperty(PlotConstants.PIN_TIME_AXIS, Boolean.toString(timeAxisPinned));
viewProperties.setProperty(PlotConstants.DRAW_LINES, "" + plotLineDraw.drawLine());
viewProperties.setProperty(PlotConstants.DRAW_MARKERS, "" + plotLineDraw.drawMarkers());
viewProperties.setProperty(PlotConstants.CONNECTION_TYPE, "" + plotLineConnectionType);
if (plotViewManifestation.getManifestedComponent() != null) {
plotViewManifestation.getManifestedComponent().save();
plotViewManifestation.updateMonitoredGUI();
}
}
/**
* Retrieve persisted per-line plot settings (feed color assignments, line thicknesses, etc).
* Each element of the returned list corresponds, in order, to the sub-plots displayed,
* and maps subscription ID to a LineSettings object describing how the line is to be displayed.
* @return the persisted line settings
*/
public List<Map<String, LineSettings>> loadLineSettingsFromPersistence() {
List<Map<String, LineSettings>> lineSettingAssignments =
new ArrayList<Map<String, LineSettings>>();
String lineSettings = plotViewManifestation.getViewProperties().getProperty(PlotConstants.LINE_SETTINGS, String.class);
if (lineSettings != null) {
for (String plot : lineSettings.split("\n")) {
Map<String, LineSettings> settingsMap = new HashMap<String, LineSettings>();
for (String line : plot.split("\t")) {
LineSettings settings = new LineSettings();
String[] tokens = line.split(" ");
try {
int i = 0;
if (tokens.length > i) settings.setIdentifier ( tokens[i++] );
if (tokens.length > i) settings.setColorIndex (Integer.parseInt (tokens[i++]));
if (tokens.length > i) settings.setThickness (Integer.parseInt (tokens[i++]));
if (tokens.length > i) settings.setMarker (Integer.parseInt (tokens[i++]));
if (tokens.length > i) settings.setCharacter ( tokens[i++] );
if (tokens.length > i) settings.setUseCharacter (Boolean.parseBoolean(tokens[i++]));
if (tokens.length > i) settings.setHasRegression (Boolean.parseBoolean(tokens[i++]));
if (tokens.length > i) settings.setRegressionPoints(Integer.parseInt (tokens[i++]));
} catch (Exception e) {
logger.error("Could not parse plot line settings from persistence", e);
}
if (!settings.getIdentifier().isEmpty()) {
settingsMap.put(settings.getIdentifier(), settings);
}
}
lineSettingAssignments.add(settingsMap);
}
}
/* Merge in color assignments, if specified */
List<Map<String, Integer>> colorAssignments = getColorAssignments();
for (int i = 0; i < Math.min(colorAssignments.size(), lineSettingAssignments.size()); i++) {
Map<String, LineSettings> settingsMap = lineSettingAssignments.get(i);
for (Entry<String, Integer> e : colorAssignments.get(i).entrySet()) {
if (!settingsMap.containsKey(e.getKey())) { // Only override unspecified settings
LineSettings settings = new LineSettings();
settings.setIdentifier(e.getKey());
settings.setColorIndex(e.getValue());
settings.setMarker(e.getValue()); // Use same index for markers by default
settingsMap.put(e.getKey(), settings);
}
}
}
return lineSettingAssignments;
}
private List<Map<String, Integer>> getColorAssignments() {
String colorAssignmentString = plotViewManifestation.getViewProperties().getProperty(PlotConstants.COLOR_ASSIGNMENTS, String.class);
List<Map<String, Integer>> colorAssignments = new ArrayList<Map<String, Integer>>();
if (colorAssignmentString != null) {
StringTokenizer allAssignmentTokens = new StringTokenizer(colorAssignmentString, "\n");
while (allAssignmentTokens.hasMoreTokens()) {
StringTokenizer colorAssignmentTokens = new StringTokenizer(allAssignmentTokens.nextToken(), "\t");
Map<String, Integer> subPlotMap = new HashMap<String, Integer>();
colorAssignments.add(subPlotMap);
while (colorAssignmentTokens.hasMoreTokens()) {
String dataSet = colorAssignmentTokens.nextToken();
int colorIndex = Integer.parseInt(colorAssignmentTokens.nextToken());
subPlotMap.put(dataSet, colorIndex);
}
}
}
return colorAssignments;
}
public void persistLineSettings(List<Map<String, LineSettings>> lineSettings) {
StringBuilder lineSettingsBuilder = new StringBuilder(lineSettings.size() * 100);
for (Map<String, LineSettings> subPlotMap : lineSettings) {
for (Entry<String, LineSettings> entry : subPlotMap.entrySet()) {
LineSettings settings = entry.getValue();
lineSettingsBuilder.append(entry.getKey());
lineSettingsBuilder.append(' ');
lineSettingsBuilder.append(settings.getColorIndex());
lineSettingsBuilder.append(' ');
lineSettingsBuilder.append(settings.getThickness());
lineSettingsBuilder.append(' ');
lineSettingsBuilder.append(settings.getMarker()); //Marker
lineSettingsBuilder.append(' ');
lineSettingsBuilder.append(settings.getCharacter().replaceAll(" ", "_")); //Character
lineSettingsBuilder.append(' ');
lineSettingsBuilder.append(Boolean.toString(settings.getUseCharacter())); //Whether to use character as marker
lineSettingsBuilder.append(' ');
lineSettingsBuilder.append(Boolean.toString(settings.getHasRegression()));
lineSettingsBuilder.append(' ');
lineSettingsBuilder.append(settings.getRegressionPoints());
lineSettingsBuilder.append('\t');
}
lineSettingsBuilder.append('\n');
}
ExtendedProperties viewProperties = plotViewManifestation.getViewProperties();
viewProperties.setProperty(PlotConstants.LINE_SETTINGS, lineSettingsBuilder.toString());
if (plotViewManifestation.getManifestedComponent() != null) {
plotViewManifestation.getManifestedComponent().save();
}
}
} | false | fastPlotViews_src_main_java_gov_nasa_arc_mct_fastplot_view_PlotPersistanceHandler.java |
747 | public class PlotSettingController {
AxisOrientationSetting timeAxisSetting;
XAxisMaximumLocationSetting xAxisMaximumLocation;
YAxisMaximumLocationSetting yAxisMaximumLocation;
TimeAxisSubsequentBoundsSetting timeAxisSubsequentSetting;
NonTimeAxisSubsequentBoundsSetting nonTimeAxisSubsequentMinSetting;
NonTimeAxisSubsequentBoundsSetting nonTimeAxisSubsequentMaxSetting;
double nonTimeMax;
double nonTimeMin;
GregorianCalendar minTime;
GregorianCalendar maxTime;
double timePadding = 0;
double nonTimeMinPadding = 0;
double nonTimeMaxPadding = 0;
boolean useOrdinalPositionForSubplots;
boolean timeAxisPinned;
PlotLineDrawingFlags plotLineDraw;
PlotLineConnectionType plotLineConnectionType;
private static Logger logger = LoggerFactory.getLogger(PlotSettingController.class);
// Panel controller is controlling
private PlotSettingsControlPanel panel;
/**
* Construct controller defining the panel to connect to.
* @param panel the panel to control.
* @throws IllegalArgumentExcpetion if panel is null.
*/
PlotSettingController(PlotSettingsControlPanel inputPanel) {
if (inputPanel == null) {
throw new IllegalArgumentException();
}
panel = inputPanel;
}
public void setTimeAxis(AxisOrientationSetting setting) {
timeAxisSetting = setting;
}
public void setXAxisMaximumLocation(XAxisMaximumLocationSetting setting) {
xAxisMaximumLocation = setting;
}
public void setYAxisMaximumLocation(YAxisMaximumLocationSetting setting) {
yAxisMaximumLocation = setting;
}
public void setTimeAxisPinned(boolean pinned) {
timeAxisPinned = pinned;
}
public void setTimeAxisSubsequentBounds(TimeAxisSubsequentBoundsSetting setting) {
timeAxisSubsequentSetting = setting;
}
public void setNonTimeAxisSubsequentMinBounds(NonTimeAxisSubsequentBoundsSetting setting) {
nonTimeAxisSubsequentMinSetting = setting;
}
public void setNonTimeAxisSubsequentMaxBounds(NonTimeAxisSubsequentBoundsSetting setting) {
nonTimeAxisSubsequentMaxSetting = setting;
}
public void setNonTimeMinMaxValues(double minValue, double maxValue) {
nonTimeMin = minValue;
nonTimeMax = maxValue;
}
public void setTimeMinMaxValues(GregorianCalendar lowerTime, GregorianCalendar upperTime) {
minTime = lowerTime;
maxTime = upperTime;
}
public void setTimePadding(Double padding) {
timePadding = padding;
}
public void setNonTimeMaxPadding(Double padding) {
nonTimeMaxPadding = padding;
}
public void setNonTimeMinPadding(Double padding) {
nonTimeMinPadding = padding;
}
public void setUseOrdinalPositionToGroupSubplots(boolean value) {
useOrdinalPositionForSubplots = value;
}
public void setPlotLineDraw(PlotLineDrawingFlags plotLineDraw) {
this.plotLineDraw = plotLineDraw;
}
public void setPlotLineConnectionType(
PlotLineConnectionType plotLineConnectionType) {
this.plotLineConnectionType = plotLineConnectionType;
}
/**
* Run tests to check that the plot settings panel has feed a valid state for a plot to be created.
* @return true if state is valid. False otherwise.
*/
String stateIsValid() {
if (nonTimeMin > nonTimeMax) {
return "PlotSettingsPanel passed a nonTimeMin (" + nonTimeMin +
") >= nonTimeMax (" + nonTimeMax + ") to the PlotSettingsController. Panel needs to validate this.";
}
if (minTime == null || maxTime == null) {
return "PlotSettingsPanel passed a null min or max time to the PlotSettingsController. Panel needs to validate this.";
}
if (minTime.getTimeInMillis() >= maxTime.getTimeInMillis()) {
return "PlotSettingsPanel passed a timeMin (" + minTime.getTimeInMillis() + ") >= timeMax ("
+ maxTime.getTimeInMillis() + ") to the PlotSettingsController. Panel needs to validate this.";
}
if (timePadding > 1.0 || timePadding < 0.0) {
return "PlotSettingsPanel of "+ timePadding + " passed a timePadding outside the range 0.0 .. 1.0 to PlotSettingsController. Panel needs to validate this.";
}
if (nonTimeMinPadding > 1.0 || nonTimeMaxPadding < 0.0) {
return "PlotSettingsPanel of "+ nonTimeMinPadding + " passed a nonTimeMinPadding outside the range 0.0 .. 1.0 to PlotSettingsController. Panel needs to validate this.";
}
if (nonTimeMaxPadding > 1.0 || nonTimeMaxPadding < 0.0) {
return "PlotSettingsPanel of "+ nonTimeMaxPadding + " passed a nonTimeMaxPadding outside the range 0.0 .. 1.0 to PlotSettingsController. Panel needs to validate this.";
}
if (timeAxisSetting == null) {
return "PlotSettingsPanel passed a null timeAxisSetting to the PlotSettingsController. Panel needs to validate this.";
}
if (xAxisMaximumLocation == null) {
return "PlotSettingsPanel passed a null xAxisMaximumLocation to the PlotSettingsController. Panel needs to validate this.";
}
if (timeAxisSubsequentSetting == null) {
return "PlotSettingsPanel passed a null timeAxisSubsequentSetting to the PlotSettingsController. Panel needs to validate this.";
}
if (nonTimeAxisSubsequentMinSetting == null) {
return "PlotSettingsPanel passed a null nonTimeAxisSubsequentMinSetting to the PlotSettingsController. Panel needs to validate this.";
}
if (nonTimeAxisSubsequentMaxSetting == null) {
return "PlotSettingsPanel passed a null nonTimeAxisSubsequentMaxSetting to the PlotSettingsController. Panel needs to validate this.";
}
return null;
}
/*
* Call when user presses create chart button
*/
public void createPlot() {
// Only create a new plot if the state passed from plot settings panel is valid.
String badStateMessage = stateIsValid();
// Cause a hard assertion failure when running in development environment.
assert (badStateMessage == null) : "Plot setting panel passed a bad state to the plot " + badStateMessage;
// Display an error message in production environment.
if (badStateMessage != null) {
logger.error(badStateMessage);
} else {
// The state is good so that we can crate the plot.
panel.getPlot().setupPlot(timeAxisSetting,
xAxisMaximumLocation,
yAxisMaximumLocation,
timeAxisSubsequentSetting,
nonTimeAxisSubsequentMinSetting,
nonTimeAxisSubsequentMaxSetting,
nonTimeMax,
nonTimeMin,
minTime,
maxTime,
timePadding,
nonTimeMaxPadding,
nonTimeMinPadding,
useOrdinalPositionForSubplots,
timeAxisPinned,
plotLineDraw,
plotLineConnectionType
);
}
}
} | false | fastPlotViews_src_main_java_gov_nasa_arc_mct_fastplot_view_PlotSettingController.java |
748 | public class PlotSettingsControlPanel extends JPanel {
private static final long serialVersionUID = 6158825155688815494L;
// Access bundle file where externalized strings are defined.
private static final ResourceBundle BUNDLE =
ResourceBundle.getBundle(PlotSettingsControlPanel.class.getName().substring(0,
PlotSettingsControlPanel.class.getName().lastIndexOf("."))+".Bundle");
private final static Logger logger = LoggerFactory.getLogger(PlotSettingsControlPanel.class);
private static final String MANUAL_LABEL = BUNDLE.getString("Manual.label");
private static final int INTERCONTROL_HORIZONTAL_SPACING = 0;
private static final int INDENTATION_SEMI_FIXED_CHECKBOX = 16;
private static final int NONTIME_TITLE_SPACING = 0;
private static final int Y_SPAN_SPACING = 50;
private static final int INNER_PADDING = 5;
private static final int INNER_PADDING_TOP = 5;
private static final int X_AXIS_TYPE_VERTICAL_SPACING = 2;
private static final Border TOP_PADDED_MARGINS = BorderFactory.createEmptyBorder(5, 0, 0, 0);
private static final Border BOTTOM_PADDED_MARGINS = BorderFactory.createEmptyBorder(0, 0, 2, 0);
private static final int BEHAVIOR_CELLS_X_PADDING = 18;
private static final Border CONTROL_PANEL_MARGINS = BorderFactory.createEmptyBorder(INNER_PADDING_TOP, INNER_PADDING, INNER_PADDING, INNER_PADDING);
private static final Border SETUP_AND_BEHAVIOR_MARGINS = BorderFactory.createEmptyBorder(0, INNER_PADDING, INNER_PADDING, INNER_PADDING);
// Stabilize width of panel on left of the static plot image
private static final Dimension Y_AXIS_BUTTONS_PANEL_PREFERRED_SIZE = new Dimension(250, 0);
private static final Double NONTIME_AXIS_SPAN_INIT_VALUE = Double.valueOf(30);
private static final int JTEXTFIELD_COLS = 8;
private static final int NUMERIC_TEXTFIELD_COLS1 = 12;
private static final DecimalFormat nonTimePaddingFormat = new DecimalFormat("###.###");
private static final DecimalFormat timePaddingFormat = new DecimalFormat("##.###");
private static final String DATE_FORMAT = "D/HH:mm:ss";
private SimpleDateFormat dateFormat = new SimpleDateFormat(DATE_FORMAT);
static GregorianCalendar ZERO_TIME_SPAN_CALENDAR = new GregorianCalendar();
static {
ZERO_TIME_SPAN_CALENDAR.set(Calendar.DAY_OF_YEAR, 1);
ZERO_TIME_SPAN_CALENDAR.set(Calendar.HOUR_OF_DAY, 0);
ZERO_TIME_SPAN_CALENDAR.set(Calendar.MINUTE, 0);
ZERO_TIME_SPAN_CALENDAR.set(Calendar.SECOND, 0);
}
private static Date ZERO_TIME_SPAN_DATE = new Date();
static {
// Sets value to current Year and time zone
GregorianCalendar cal = new GregorianCalendar();
cal.set(Calendar.DAY_OF_YEAR, 1);
cal.set(Calendar.HOUR_OF_DAY, 0);
cal.set(Calendar.MINUTE, 0);
cal.set(Calendar.SECOND, 0);
ZERO_TIME_SPAN_DATE.setTime(cal.getTimeInMillis());
}
// Space between paired controls (e.g., label followed by text field)
private static final int SPACE_BETWEEN_ROW_ITEMS = 3;
private static final Color OK_PANEL_BACKGROUND_COLOR = LafColor.WINDOW_BORDER.darker();
private static final int PADDING_COLUMNS = 3;
// Maintain link to the plot view this panel is supporting.
private PlotViewManifestation plotViewManifestion;
// Maintain link to the controller this panel is calling to persist setting and create the plot
PlotSettingController controller;
// Non-Time Axis Maximums panel
NonTimeAxisMaximumsPanel nonTimeAxisMaximumsPanel;
// Non-Time Axis Minimums panel
NonTimeAxisMinimumsPanel nonTimeAxisMinimumsPanel;
//Time Axis Minimums panel
public TimeAxisMinimumsPanel timeAxisMinimumsPanel;
//Time Axis Maximums panel
public TimeAxisMaximumsPanel timeAxisMaximumsPanel;
// Top panel controls: Manipulate controls around static plot image
private JComboBox timeDropdown;
JRadioButton xAxisAsTimeRadioButton;
JRadioButton yAxisAsTimeRadioButton;
private JRadioButton yMaxAtTop;
private JRadioButton yMaxAtBottom;
private JRadioButton xMaxAtRight;
private JRadioButton xMaxAtLeft;
private JCheckBox groupByCollection;
//=========================================================================
/*
* X Axis panels
*/
XAxisSpanCluster xAxisSpanCluster;
XAxisAdjacentPanel xAxisAdjacentPanel;
// Join minimums and maximums panels
XAxisButtonsPanel xAxisButtonsPanel;
JLabel xMinLabel;
JLabel xMaxLabel;
private JLabel xAxisType;
//=========================================================================
/*
* Y Axis panels
*/
YMaximumsPlusPanel yMaximumsPlusPanel;
YAxisSpanPanel yAxisSpanPanel;
YMinimumsPlusPanel yMinimumsPlusPanel;
private YAxisButtonsPanel yAxisButtonsPanel;
private JLabel yAxisType;
/*
* Time Axis fields
*/
JRadioButton timeAxisMaxAuto;
ParenthesizedTimeLabel timeAxisMaxAutoValue;
JRadioButton timeAxisMaxManual;
TimeTextField timeAxisMaxManualValue;
JRadioButton timeAxisMinAuto;
ParenthesizedTimeLabel timeAxisMinAutoValue;
JRadioButton timeAxisMinManual;
TimeTextField timeAxisMinManualValue;
TimeSpanTextField timeSpanValue;
public JRadioButton timeAxisMinCurrent;
public JRadioButton timeAxisMaxCurrent;
public ParenthesizedTimeLabel timeAxisMinCurrentValue;
public ParenthesizedTimeLabel timeAxisMaxCurrentValue;
/*
* Non-time Axis fields
*/
JRadioButton nonTimeAxisMaxCurrent;
ParenthesizedNumericLabel nonTimeAxisMaxCurrentValue;
JRadioButton nonTimeAxisMaxManual;
NumericTextField nonTimeAxisMaxManualValue;
JRadioButton nonTimeAxisMaxAutoAdjust;
ParenthesizedNumericLabel nonTimeAxisMaxAutoAdjustValue;
JRadioButton nonTimeAxisMinCurrent;
ParenthesizedNumericLabel nonTimeAxisMinCurrentValue;
JRadioButton nonTimeAxisMinManual;
NumericTextField nonTimeAxisMinManualValue;
JRadioButton nonTimeAxisMinAutoAdjust;
ParenthesizedNumericLabel nonTimeAxisMinAutoAdjustValue;
NumericTextField nonTimeSpanValue;
/*
* Plot Behavior panel controls
*/
JRadioButton nonTimeMinAutoAdjustMode;
JRadioButton nonTimeMaxAutoAdjustMode;
JRadioButton nonTimeMinFixedMode;
JRadioButton nonTimeMaxFixedMode;
JCheckBox nonTimeMinSemiFixedMode;
JCheckBox nonTimeMaxSemiFixedMode;
JTextField nonTimeMinPadding;
JTextField nonTimeMaxPadding;
JCheckBox pinTimeAxis;
JRadioButton timeJumpMode;
JRadioButton timeScrunchMode;
JTextField timeJumpPadding;
JTextField timeScrunchPadding;
/*
* Plot line setup panel controls
*/
private JLabel drawLabel;
private JRadioButton linesOnly;
private JRadioButton markersAndLines;
private JRadioButton markersOnly;
private JLabel connectionLineTypeLabel;
private JRadioButton direct;
private JRadioButton step;
private StillPlotImagePanel imagePanel;
private JLabel behaviorTimeAxisLetter;
private JLabel behaviorNonTimeAxisLetter;
private GregorianCalendar recycledCalendarA = new GregorianCalendar();
private GregorianCalendar recycledCalendarB = new GregorianCalendar();
private JButton okButton;
private JButton resetButton;
// Saved Settings of Plot Settings Panel controls. Used to affect Apply and Reset buttons
private Object ssWhichAxisAsTime;
private Object ssXMaxAtWhich;
private Object ssYMaxAtWhich;
private Object ssTimeMin;
private Object ssTimeMax;
private Object ssNonTimeMin;
private Object ssNonTimeMax;
private Object ssTimeAxisMode;
private Object ssPinTimeAxis;
private List<JToggleButton> ssNonTimeMinAxisMode = new ArrayList<JToggleButton>(2);
private List<JToggleButton> ssNonTimeMaxAxisMode = new ArrayList<JToggleButton>(2);
private String ssNonTimeMinPadding;
private String ssNonTimeMaxPadding;
private String ssTimeAxisJumpMaxPadding;
private String ssTimeAxisScrunchMaxPadding;
private Object ssDraw;
private Object ssConnectionLineType;
// Initialize this to avoid nulls on persistence
private long ssTimeMinManualValue = 0L;
private long ssTimeMaxManualValue = 0L;
private String ssNonTimeMinManualValue = "0.0";
private String ssNonTimeMaxManualValue = "1.0";
private boolean timeMinManualHasBeenSelected = false;
private boolean timeMaxManualHasBeenSelected = false;
private boolean ssGroupByCollection = false;
//===================================================================================
public static class CalendarDump {
public static String dumpDateAndTime(GregorianCalendar calendar) {
StringBuilder buffer = new StringBuilder();
buffer.append(calendar.get(Calendar.YEAR) + " - ");
buffer.append(calendar.get(Calendar.DAY_OF_YEAR) + "/");
buffer.append(calendar.get(Calendar.HOUR_OF_DAY) + ":");
buffer.append(calendar.get(Calendar.MINUTE) + ":");
buffer.append(calendar.get(Calendar.SECOND));
buffer.append(", Zone " + (calendar.get(Calendar.ZONE_OFFSET) / (3600 * 1000)));
return buffer.toString();
}
public static String dumpMillis(long timeInMillis) {
GregorianCalendar cal = new GregorianCalendar();
cal.setTimeInMillis(timeInMillis);
return dumpDateAndTime(cal);
}
}
class ParenthesizedTimeLabel extends JLabel {
private static final long serialVersionUID = -6004293775277749905L;
private GregorianCalendar timeInMillis;
private JRadioButton companionButton;
public ParenthesizedTimeLabel(JRadioButton button) {
companionButton = button;
this.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
companionButton.setSelected(true);
companionButton.requestFocusInWindow();
updateMainButtons();
}
});
}
public void setTime(GregorianCalendar inputTime) {
timeInMillis = inputTime;
setText("(" + dateFormat.format(inputTime.getTime()) + ")");
}
public GregorianCalendar getCalendar() {
return timeInMillis;
}
public long getTimeInMillis() {
return timeInMillis.getTimeInMillis();
}
public String getSavedTime() {
return CalendarDump.dumpDateAndTime(timeInMillis);
}
public int getSecond() {
return timeInMillis.get(Calendar.SECOND);
}
public int getMinute() {
return timeInMillis.get(Calendar.MINUTE);
}
public int getHourOfDay() {
return timeInMillis.get(Calendar.HOUR_OF_DAY);
}
}
class ParenthesizedNumericLabel extends JLabel {
private static final long serialVersionUID = 3403375470853249483L;
private JRadioButton companionButton;
public ParenthesizedNumericLabel(JRadioButton button) {
companionButton = button;
this.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
companionButton.setSelected(true);
companionButton.requestFocusInWindow();
updateMainButtons();
}
});
}
public Double getValue() {
String data = getText();
if (data == null) {
return null;
}
if (data.length() < 3) {
logger.error("Numeric label in plot settings contained invalid content [" + data + "]");
return null;
}
Double result = null;
try {
result = Double.parseDouble(data.substring(1, data.length() - 1));
} catch(NumberFormatException e) {
logger.error("Could not parse numeric value from ["+ data.substring(1, data.length() - 1) + "]");
}
return result;
}
public void setValue(Double input) {
String formatNum = nonTimePaddingFormat.format(input);
if (formatNum.equals("0"))
formatNum = "0.0";
if (formatNum.equals("1"))
formatNum = "1.0";
setText("(" + formatNum + ")");
}
}
/*
* Focus listener for the Time axis Manual and Span fields
*/
class TimeFieldFocusListener extends FocusAdapter {
// This class can be used with a null button
private JRadioButton companionButton;
public TimeFieldFocusListener(JRadioButton assocButton) {
companionButton = assocButton;
}
@Override
public void focusGained(FocusEvent e) {
if (e.isTemporary())
return;
if (companionButton != null) {
companionButton.setSelected(true);
}
updateMainButtons();
}
@Override
public void focusLost(FocusEvent e) {
if (e.isTemporary())
return;
try {
timeSpanValue.commitEdit();
} catch (ParseException exception) {
exception.printStackTrace();
}
updateTimeAxisControls();
}
}
/*
* Common action listener for the Time axis Mode buttons
*/
class TimeAxisModeListener implements ActionListener {
private JTextComponent companionField;
public TimeAxisModeListener(JTextComponent field) {
companionField = field;
}
@Override
public void actionPerformed(ActionEvent e) {
updateMainButtons();
String content = companionField.getText();
companionField.requestFocusInWindow();
companionField.setSelectionStart(0);
if (content != null) {
companionField.setSelectionEnd(content.length());
}
}
}
/*
* Focus listener for the Time Padding fields
*/
class TimePaddingFocusListener extends FocusAdapter {
@Override
public void focusLost(FocusEvent e) {
if (e.isTemporary())
return;
updateTimeAxisControls();
}
}
class NonTimeFieldFocusListener extends FocusAdapter {
private JRadioButton companionButton;
public NonTimeFieldFocusListener(JRadioButton assocButton) {
companionButton = assocButton;
}
@Override
public void focusGained(FocusEvent e) {
if (e.isTemporary())
return;
companionButton.setSelected(true);
updateNonTimeAxisControls();
}
@Override
public void focusLost(FocusEvent e) {
if (e.isTemporary())
return;
updateNonTimeAxisControls();
}
}
/*
* Guide to the inner classes implementing the movable panels next to the static plot image
*
* XAxisAdjacentPanel - Narrow panel just below X axis
* XAxisSpanCluster - child panel
* XAxisButtonsPanel - Main panel below X axis
* minimumsPanel - child
* maximumsPanel - child
*
* YAxisButtonsPanel - Main panel to left of Y axis
* YMaximumsPlusPanel - child panel
* YSpanPanel - child
* YMinimumsPlusPanel - child
*
*/
// Panel holding the Y Axis Span controls
class YAxisSpanPanel extends JPanel {
private static final long serialVersionUID = 6888092349514542052L;
private JLabel ySpanTag;
private JComponent spanValue;
private Component boxGlue;
private Component boxOnRight;
public YAxisSpanPanel() {
setLayout(new BoxLayout(this, BoxLayout.X_AXIS));
nonTimePaddingFormat.setParseIntegerOnly(false);
nonTimeSpanValue = new NumericTextField(NUMERIC_TEXTFIELD_COLS1, nonTimePaddingFormat);
nonTimeSpanValue.setColumns(JTEXTFIELD_COLS);
nonTimeSpanValue.setValue(NONTIME_AXIS_SPAN_INIT_VALUE);
spanValue = nonTimeSpanValue;
ySpanTag = new JLabel("Span: ");
boxGlue = Box.createHorizontalGlue();
boxOnRight = Box.createRigidArea(new Dimension(Y_SPAN_SPACING, 0));
layoutPanel();
// Instrument
ySpanTag.setName("ySpanTag");
}
void layoutPanel() {
removeAll();
add(boxGlue);
add(ySpanTag);
add(spanValue);
add(boxOnRight);
}
void setSpanField(JComponent field) {
spanValue = field;
layoutPanel();
}
}
// Panel holding the combined "Min" label and Y Axis minimums panel
class YMinimumsPlusPanel extends JPanel {
private static final long serialVersionUID = 2995723041366974233L;
private JPanel coreMinimumsPanel;
private JLabel minJLabel = new JLabel("Min");
public YMinimumsPlusPanel() {
setLayout(new BoxLayout(this, BoxLayout.X_AXIS));
minJLabel.setAlignmentY(Component.BOTTOM_ALIGNMENT);
minJLabel.setFont(minJLabel.getFont().deriveFont(Font.BOLD));
nonTimeAxisMinimumsPanel = new NonTimeAxisMinimumsPanel();
nonTimeAxisMinimumsPanel.setAlignmentY(Component.BOTTOM_ALIGNMENT);
minJLabel.setAlignmentY(Component.BOTTOM_ALIGNMENT);
add(nonTimeAxisMinimumsPanel);
add(minJLabel);
// Instrument
minJLabel.setName("minJLabel");
}
public void setPanel(JPanel minPanel) {
coreMinimumsPanel = minPanel;
removeAll();
add(coreMinimumsPanel);
add(minJLabel);
revalidate();
}
public void setAxisTagAlignment(float componentAlignment) {
coreMinimumsPanel.setAlignmentY(componentAlignment);
minJLabel.setAlignmentY(componentAlignment);
}
}
// Panel holding the combined "Max" label and Y Axis maximums panel
class YMaximumsPlusPanel extends JPanel {
private static final long serialVersionUID = -7611052255395258026L;
private JPanel coreMaximumsPanel;
private JLabel maxJLabel = new JLabel("Max");
public YMaximumsPlusPanel() {
setLayout(new BoxLayout(this, BoxLayout.X_AXIS));
maxJLabel.setAlignmentY(Component.TOP_ALIGNMENT);
maxJLabel.setFont(maxJLabel.getFont().deriveFont(Font.BOLD));
nonTimeAxisMaximumsPanel = new NonTimeAxisMaximumsPanel();
nonTimeAxisMaximumsPanel.setAlignmentY(Component.TOP_ALIGNMENT);
maxJLabel.setAlignmentY(Component.TOP_ALIGNMENT);
add(nonTimeAxisMaximumsPanel);
add(maxJLabel);
// Instrument
maxJLabel.setName("maxJLabel");
}
public void setPanel(JPanel maxPanel) {
coreMaximumsPanel = maxPanel;
removeAll();
add(coreMaximumsPanel);
add(maxJLabel);
revalidate();
}
public void setAxisTagAlignment(float componentAlignment) {
coreMaximumsPanel.setAlignmentY(componentAlignment);
maxJLabel.setAlignmentY(componentAlignment);
revalidate();
}
}
// Panel holding the Time Axis minimum controls
class TimeAxisMinimumsPanel extends JPanel {
private static final long serialVersionUID = 3651502189841560982L;
public TimeAxisMinimumsPanel() {
setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
timeAxisMinCurrent = new JRadioButton(BUNDLE.getString("Currentmin.label"));
timeAxisMinCurrentValue = new ParenthesizedTimeLabel(timeAxisMinCurrent);
timeAxisMinCurrentValue.setTime(new GregorianCalendar());
timeAxisMinManual = new JRadioButton(MANUAL_LABEL);
MaskFormatter formatter = null;
try {
formatter = new MaskFormatter("###/##:##:##");
formatter.setPlaceholderCharacter('0');
} catch (ParseException e) {
logger.error("Parse error in creating time field", e);
}
timeAxisMinManualValue = new TimeTextField(formatter);
timeAxisMinAuto = new JRadioButton(BUNDLE.getString("Now.label"));
timeAxisMinAutoValue = new ParenthesizedTimeLabel(timeAxisMinAuto);
timeAxisMinAutoValue.setTime(new GregorianCalendar());
timeAxisMinAutoValue.setText("should update every second");
timeAxisMinAuto.setSelected(true);
JPanel yAxisMinRow1 = createMultiItemRow(timeAxisMinCurrent, timeAxisMinCurrentValue);
JPanel yAxisMinRow2 = createMultiItemRow(timeAxisMinManual, timeAxisMinManualValue);
JPanel yAxisMinRow3 = createMultiItemRow(timeAxisMinAuto, timeAxisMinAutoValue);
add(yAxisMinRow1);
add(yAxisMinRow2);
add(yAxisMinRow3);
add(Box.createVerticalGlue());
ButtonGroup minButtonGroup = new ButtonGroup();
minButtonGroup.add(timeAxisMinCurrent);
minButtonGroup.add(timeAxisMinManual);
minButtonGroup.add(timeAxisMinAuto);
timeAxisMinAuto.setToolTipText(BUNDLE.getString("TimeAxisMins.label"));
}
}
// Panel holding the Time Axis maximum controls
class TimeAxisMaximumsPanel extends JPanel {
private static final long serialVersionUID = 6105026690366452860L;
public TimeAxisMaximumsPanel() {
setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
timeAxisMaxCurrent = new JRadioButton(BUNDLE.getString("CurrentMax.label"));
timeAxisMaxCurrentValue = new ParenthesizedTimeLabel(timeAxisMaxCurrent);
GregorianCalendar initCalendar = new GregorianCalendar();
initCalendar.add(Calendar.MINUTE, 10);
timeAxisMaxCurrentValue.setTime(initCalendar);
timeAxisMaxManual = new JRadioButton(MANUAL_LABEL);
MaskFormatter formatter = null;
try {
formatter = new MaskFormatter("###/##:##:##");
formatter.setPlaceholderCharacter('0');
} catch (ParseException e) {
e.printStackTrace();
}
timeAxisMaxManualValue = new TimeTextField(formatter);
initCalendar.setTimeInMillis(timeAxisMaxManualValue.getValueInMillis() + 1000);
timeAxisMaxManualValue.setTime(initCalendar);
timeAxisMaxAuto = new JRadioButton(BUNDLE.getString("MinPlusSpan.label"));
timeAxisMaxAutoValue = new ParenthesizedTimeLabel(timeAxisMaxAuto);
timeAxisMaxAutoValue.setTime(initCalendar);
JPanel yAxisMaxRow1 = createMultiItemRow(timeAxisMaxCurrent, timeAxisMaxCurrentValue);
JPanel yAxisMaxRow2 = createMultiItemRow(timeAxisMaxManual, timeAxisMaxManualValue);
JPanel yAxisMaxRow3 = createMultiItemRow(timeAxisMaxAuto, timeAxisMaxAutoValue);
timeAxisMaxAuto.setSelected(true);
add(yAxisMaxRow1);
add(yAxisMaxRow2);
add(yAxisMaxRow3);
add(Box.createVerticalGlue());
ButtonGroup maxButtonGroup = new ButtonGroup();
maxButtonGroup.add(timeAxisMaxCurrent);
maxButtonGroup.add(timeAxisMaxManual);
maxButtonGroup.add(timeAxisMaxAuto);
timeAxisMaxAuto.setToolTipText(BUNDLE.getString("TimeAxisMins.label"));
}
}
// Panel holding the min, max and span controls
class YAxisButtonsPanel extends JPanel {
private static final long serialVersionUID = 3430980575280458813L;
private GridBagConstraints gbcForMax;
private GridBagConstraints gbcForMin;
private GridBagConstraints gbcForSpan;
public YAxisButtonsPanel() {
setLayout(new GridBagLayout());
setPreferredSize(Y_AXIS_BUTTONS_PANEL_PREFERRED_SIZE);
// Align radio buttons for Max and Min on the left
gbcForMax = new GridBagConstraints();
gbcForMax.gridx = 0;
gbcForMax.fill = GridBagConstraints.HORIZONTAL;
gbcForMax.anchor = GridBagConstraints.WEST;
gbcForMax.weightx = 1;
gbcForMax.weighty = 0;
gbcForMin = new GridBagConstraints();
gbcForMin.gridx = 0;
gbcForMin.fill = GridBagConstraints.HORIZONTAL;
gbcForMin.anchor = GridBagConstraints.WEST;
gbcForMin.weightx = 1;
gbcForMin.weighty = 0;
// Align Span controls on the right
gbcForSpan = new GridBagConstraints();
gbcForSpan.gridx = 0;
// Let fill default to NONE and weightx default to 0
gbcForSpan.anchor = GridBagConstraints.EAST;
gbcForSpan.weighty = 1;
}
public void setNormalOrder(boolean normalDirection) {
removeAll();
if (normalDirection) {
gbcForMax.gridy = 0;
gbcForMax.anchor = GridBagConstraints.NORTHWEST;
add(yMaximumsPlusPanel, gbcForMax);
gbcForSpan.gridy = 1;
add(yAxisSpanPanel, gbcForSpan);
gbcForMin.gridy = 2;
gbcForMin.anchor = GridBagConstraints.SOUTHWEST;
add(yMinimumsPlusPanel, gbcForMin);
yMaximumsPlusPanel.setAxisTagAlignment(Component.TOP_ALIGNMENT);
yMinimumsPlusPanel.setAxisTagAlignment(Component.BOTTOM_ALIGNMENT);
} else {
gbcForMin.gridy = 0;
gbcForMin.anchor = GridBagConstraints.NORTHWEST;
add(yMinimumsPlusPanel, gbcForMin);
gbcForSpan.gridy = 1;
add(yAxisSpanPanel, gbcForSpan);
gbcForMax.gridy = 2;
gbcForMax.anchor = GridBagConstraints.SOUTHWEST;
add(yMaximumsPlusPanel, gbcForMax);
yMaximumsPlusPanel.setAxisTagAlignment(Component.BOTTOM_ALIGNMENT);
yMinimumsPlusPanel.setAxisTagAlignment(Component.TOP_ALIGNMENT);
}
revalidate();
}
public void insertMinMaxPanels(JPanel minPanel, JPanel maxPanel) {
yMinimumsPlusPanel.setPanel(minPanel);
yMaximumsPlusPanel.setPanel(maxPanel);
revalidate();
}
}
// Panel holding the X axis Minimums panel and Maximums panel
class XAxisButtonsPanel extends JPanel {
private static final long serialVersionUID = -5671943216161507045L;
private JPanel minimumsPanel;
private JPanel maximumsPanel;
private GridBagConstraints gbcLeft;
private GridBagConstraints gbcRight;
public XAxisButtonsPanel() {
this.setLayout(new GridBagLayout());
gbcLeft = new GridBagConstraints();
gbcLeft.gridx = 0;
gbcLeft.gridy = 0;
gbcLeft.fill = GridBagConstraints.BOTH;
gbcLeft.anchor = GridBagConstraints.WEST;
gbcLeft.weightx = 1;
gbcRight = new GridBagConstraints();
gbcRight.gridx = 1;
gbcRight.gridy = 0;
gbcRight.fill = GridBagConstraints.BOTH;
gbcLeft.anchor = GridBagConstraints.EAST;
gbcRight.weightx = 1;
}
public void setNormalOrder(boolean normalDirection) {
removeAll();
if (normalDirection) {
add(minimumsPanel, gbcLeft);
add(maximumsPanel, gbcRight);
} else {
add(maximumsPanel, gbcLeft);
add(minimumsPanel, gbcRight);
}
revalidate();
}
public void insertMinMaxPanels(JPanel minPanel, JPanel maxPanel) {
minimumsPanel = minPanel;
maximumsPanel = maxPanel;
}
}
// Non-time axis Minimums panel
class NonTimeAxisMinimumsPanel extends JPanel {
private static final long serialVersionUID = -2619634570876465687L;
public NonTimeAxisMinimumsPanel() {
setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
nonTimeAxisMinCurrent = new JRadioButton(BUNDLE.getString("CurrentSmallestDatum.label"), true);
nonTimeAxisMinCurrentValue = new ParenthesizedNumericLabel(nonTimeAxisMinCurrent);
nonTimeAxisMinCurrentValue.setValue(0.0);
nonTimeAxisMinManual = new JRadioButton(MANUAL_LABEL, false);
nonTimeAxisMinManualValue = new NumericTextField(NUMERIC_TEXTFIELD_COLS1, nonTimePaddingFormat);
nonTimeAxisMinManualValue.setColumns(JTEXTFIELD_COLS);
nonTimeAxisMinManualValue.setText(nonTimeAxisMinCurrentValue.getValue().toString());
nonTimeAxisMinAutoAdjust = new JRadioButton(BUNDLE.getString("MaxMinusSpan.label"), false);
nonTimeAxisMinAutoAdjustValue = new ParenthesizedNumericLabel(nonTimeAxisMinAutoAdjust);
nonTimeAxisMinAutoAdjustValue.setValue(0.0);
JPanel xAxisMinRow1 = createMultiItemRow(nonTimeAxisMinCurrent, nonTimeAxisMinCurrentValue);
JPanel xAxisMinRow2 = createMultiItemRow(nonTimeAxisMinManual, nonTimeAxisMinManualValue);
JPanel xAxisMinRow3 = createMultiItemRow(nonTimeAxisMinAutoAdjust, nonTimeAxisMinAutoAdjustValue);
ButtonGroup minimumsGroup = new ButtonGroup();
minimumsGroup.add(nonTimeAxisMinCurrent);
minimumsGroup.add(nonTimeAxisMinManual);
minimumsGroup.add(nonTimeAxisMinAutoAdjust);
// Layout
add(xAxisMinRow1);
add(xAxisMinRow2);
add(xAxisMinRow3);
nonTimeAxisMinCurrent.setToolTipText(BUNDLE.getString("NonTimeAxisMin.label"));
// Instrument
xAxisMinRow1.setName("xAxisMinRow1");
xAxisMinRow2.setName("xAxisMinRow2");
xAxisMinRow3.setName("xAxisMinRow3");
}
}
// Non-time axis Maximums panel
class NonTimeAxisMaximumsPanel extends JPanel {
private static final long serialVersionUID = -768623994853270825L;
public NonTimeAxisMaximumsPanel() {
setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
nonTimeAxisMaxCurrent = new JRadioButton(BUNDLE.getString("CurrentLargestDatum.label"), true);
nonTimeAxisMaxCurrentValue = new ParenthesizedNumericLabel(nonTimeAxisMaxCurrent);
nonTimeAxisMaxCurrentValue.setValue(1.0);
nonTimeAxisMaxManual = new JRadioButton(MANUAL_LABEL, false);
DecimalFormat format = new DecimalFormat("###.######");
format.setParseIntegerOnly(false);
nonTimeAxisMaxManualValue = new NumericTextField(NUMERIC_TEXTFIELD_COLS1, format);
nonTimeAxisMaxManualValue.setColumns(JTEXTFIELD_COLS);
nonTimeAxisMaxManualValue.setText(nonTimeAxisMaxCurrentValue.getValue().toString());
nonTimeAxisMaxAutoAdjust = new JRadioButton(BUNDLE.getString("MinPlusSpan.label"), false);
nonTimeAxisMaxAutoAdjustValue = new ParenthesizedNumericLabel(nonTimeAxisMaxAutoAdjust);
nonTimeAxisMaxAutoAdjustValue.setValue(1.0);
JPanel xAxisMaxRow1 = createMultiItemRow(nonTimeAxisMaxCurrent, nonTimeAxisMaxCurrentValue);
JPanel xAxisMaxRow2 = createMultiItemRow(nonTimeAxisMaxManual, nonTimeAxisMaxManualValue);
JPanel xAxisMaxRow3 = createMultiItemRow(nonTimeAxisMaxAutoAdjust, nonTimeAxisMaxAutoAdjustValue);
ButtonGroup maximumsGroup = new ButtonGroup();
maximumsGroup.add(nonTimeAxisMaxManual);
maximumsGroup.add(nonTimeAxisMaxCurrent);
maximumsGroup.add(nonTimeAxisMaxAutoAdjust);
// Layout
add(xAxisMaxRow1);
add(xAxisMaxRow2);
add(xAxisMaxRow3);
nonTimeAxisMaxCurrent.setToolTipText(BUNDLE.getString("NonTimeAxisMax.label"));
// Instrument
xAxisMaxRow1.setName("xAxisMaxRow1");
xAxisMaxRow2.setName("xAxisMaxRow2");
xAxisMaxRow3.setName("xAxisMaxRow3");
}
}
// Panel holding X axis tags for Min and Max, and the Span field
class XAxisAdjacentPanel extends JPanel {
private static final long serialVersionUID = 4160271246055659710L;
GridBagConstraints gbcLeft = new GridBagConstraints();
GridBagConstraints gbcRight = new GridBagConstraints();
GridBagConstraints gbcCenter = new GridBagConstraints();
public XAxisAdjacentPanel() {
this.setLayout(new GridBagLayout());
xMinLabel = new JLabel(BUNDLE.getString("Min.label"));
xMaxLabel = new JLabel(BUNDLE.getString("Max.label"));
xMinLabel.setFont(xMinLabel.getFont().deriveFont(Font.BOLD));
xMaxLabel.setFont(xMaxLabel.getFont().deriveFont(Font.BOLD));
setBorder(BOTTOM_PADDED_MARGINS);
gbcLeft.anchor = GridBagConstraints.WEST;
gbcLeft.gridx = 0;
gbcLeft.gridy = 0;
gbcLeft.weightx = 0.5;
gbcCenter.anchor = GridBagConstraints.NORTH;
gbcCenter.gridx = 1;
gbcCenter.gridy = 0;
gbcRight.anchor = GridBagConstraints.EAST;
gbcRight.gridx = 2;
gbcRight.gridy = 0;
gbcRight.weightx = 0.5;
}
public void setNormalOrder(boolean normalDirection) {
removeAll();
if (normalDirection) {
add(xMinLabel, gbcLeft);
add(xAxisSpanCluster, gbcCenter);
add(xMaxLabel, gbcRight);
} else {
add(xMaxLabel, gbcLeft);
add(xAxisSpanCluster, gbcCenter);
add(xMinLabel, gbcRight);
}
revalidate();
}
}
// Panel holding X axis Span controls
class XAxisSpanCluster extends JPanel {
private static final long serialVersionUID = -3947426156383446643L;
private JComponent spanValue;
private JLabel spanTag;
private Component boxStrut;
public XAxisSpanCluster() {
setLayout(new BoxLayout(this, BoxLayout.X_AXIS));
spanTag = new JLabel("Span: ");
// Create a text field with a ddd/hh:mm:ss format for time
MaskFormatter formatter = null;
try {
formatter = new MaskFormatter("###/##:##:##");
formatter.setPlaceholderCharacter('0');
} catch (ParseException e) {
logger.error("Error in creating a mask formatter", e);
}
timeSpanValue = new TimeSpanTextField(formatter);
spanValue = timeSpanValue;
boxStrut = Box.createHorizontalStrut(INTERCONTROL_HORIZONTAL_SPACING);
layoutPanel();
// Instrument
spanTag.setName("spanTag");
}
void layoutPanel() {
removeAll();
add(spanTag);
add(boxStrut);
add(spanValue);
}
void setSpanField(JComponent field) {
spanValue = field;
layoutPanel();
}
}
// Panel that holds the still image of a plot in the Initial Settings area
public class StillPlotImagePanel extends JPanel {
private static final long serialVersionUID = 8645833372400367908L;
private JLabel timeOnXAxisNormalPicture;
private JLabel timeOnYAxisNormalPicture;
private JLabel timeOnXAxisReversedPicture;
private JLabel timeOnYAxisReversedPicture;
public StillPlotImagePanel() {
timeOnXAxisNormalPicture = new JLabel("", IconLoader.INSTANCE.getIcon(IconLoader.Icons.PLOT_TIME_ON_X_NORMAL), JLabel.CENTER);
timeOnYAxisNormalPicture = new JLabel("", IconLoader.INSTANCE.getIcon(IconLoader.Icons.PLOT_TIME_ON_Y_NORMAL), JLabel.CENTER);
timeOnXAxisReversedPicture = new JLabel("", IconLoader.INSTANCE.getIcon(IconLoader.Icons.PLOT_TIME_ON_X_REVERSED), JLabel.CENTER);
timeOnYAxisReversedPicture = new JLabel("", IconLoader.INSTANCE.getIcon(IconLoader.Icons.PLOT_TIME_ON_Y_REVERSED), JLabel.CENTER);
add(timeOnXAxisNormalPicture); // default
// Instrument
timeOnXAxisNormalPicture.setName("timeOnXAxisNormalPicture");
timeOnYAxisNormalPicture.setName("timeOnYAxisNormalPicture");
timeOnXAxisReversedPicture.setName("timeOnXAxisReversedPicture");
timeOnYAxisReversedPicture.setName("timeOnYAxisReversedPicture");
}
public void setImageToTimeOnXAxis(boolean normalDirection) {
removeAll();
if (normalDirection) {
add(timeOnXAxisNormalPicture);
} else {
add(timeOnXAxisReversedPicture);
}
revalidate();
}
public void setImageToTimeOnYAxis(boolean normalDirection) {
removeAll();
if (normalDirection) {
add(timeOnYAxisNormalPicture);
} else {
add(timeOnYAxisReversedPicture);
}
revalidate();
}
}
/* ================================================
* Main Constructor for Plot Settings Control panel
* ================================================
*/
public PlotSettingsControlPanel(PlotViewManifestation plotMan) {
// This sets the display of date/time fields that use this format object to use GMT
dateFormat.setTimeZone(TimeZone.getTimeZone(PlotConstants.DEFAULT_TIME_ZONE));
// store reference to the plot
plotViewManifestion = plotMan;
// Create controller for this panel.
controller = new PlotSettingController(this);
setLayout(new BorderLayout());
setBorder(CONTROL_PANEL_MARGINS);
addAncestorListener(new AncestorListener () {
@Override
public void ancestorAdded(AncestorEvent event) {
}
@Override
public void ancestorMoved(AncestorEvent event) {
}
@Override
public void ancestorRemoved(AncestorEvent event) {
// this could be changed to use resetButton.doClick();
ActionListener[] resetListeners = resetButton.getActionListeners();
if (resetListeners.length == 1) {
resetListeners[0].actionPerformed(null);
} else {
logger.error("Reset button has unexpected listeners.");
}
}
});
// Assemble the panel contents - two collapsible panels
JPanel overallPanel = new JPanel();
overallPanel.setLayout(new BoxLayout(overallPanel, BoxLayout.Y_AXIS));
JPanel controlsAPanel = new SectionPanel(BUNDLE.getString("PlotSetup.label"), getInitialSetupPanel());
JPanel controlsBPanel = new SectionPanel(BUNDLE.getString("WhenSpaceRunsOut.label"), getPlotBehaviorPanel());
JPanel controlsCPanel = new SectionPanel(BUNDLE.getString("LineSetup.label"), getLineSetupPanel());
overallPanel.add(controlsAPanel);
overallPanel.add(Box.createRigidArea(new Dimension(0, 7)));
overallPanel.add(controlsBPanel);
overallPanel.add(Box.createRigidArea(new Dimension(0, 7)));
overallPanel.add(controlsCPanel);
// Use panels and layouts to achieve desired spacing
JPanel squeezeBox = new JPanel(new BorderLayout());
squeezeBox.add(overallPanel, BorderLayout.NORTH);
PlotControlsLayout controlsLayout = new PlotControlsLayout();
PlotControlsLayout.ResizersScrollPane scroller =
controlsLayout.new ResizersScrollPane(squeezeBox, controlsAPanel, controlsBPanel);
scroller.setBorder(BorderFactory.createEmptyBorder());
JPanel paddableOverallPanel = new JPanel(controlsLayout);
paddableOverallPanel.add(scroller, PlotControlsLayout.MIDDLE);
paddableOverallPanel.add(createApplyButtonPanel(), PlotControlsLayout.LOWER);
add(paddableOverallPanel, BorderLayout.CENTER);
behaviorTimeAxisLetter.setText("X");
behaviorNonTimeAxisLetter.setText("Y");
// Set the initial value of the Time Min Auto value ("Now")
GregorianCalendar nextTime = new GregorianCalendar();
nextTime.setTimeInMillis(plotViewManifestion.getCurrentMCTTime());
nextTime.setTimeZone(TimeZone.getTimeZone(PlotConstants.DEFAULT_TIME_ZONE));
if (nextTime.getTimeInMillis() == 0.0) {
nextTime = plotViewManifestion.getPlot().getMinTime();
nextTime.setTimeZone(TimeZone.getTimeZone(PlotConstants.DEFAULT_TIME_ZONE));
}
timeAxisMinAutoValue.setTime(nextTime);
instrumentNames();
// Initialize state of control panel to match that of the plot.
PlotAbstraction plot = plotViewManifestion.getPlot();
if (plot!=null){
setControlPanelState(plot.getAxisOrientationSetting(),
plot.getXAxisMaximumLocation(),
plot.getYAxisMaximumLocation(),
plot.getTimeAxisSubsequentSetting(),
plot.getNonTimeAxisSubsequentMinSetting(),
plot.getNonTimeAxisSubsequentMaxSetting(),
plot.getNonTimeMax(),
plot.getNonTimeMin(),
plot.getTimeMin(),
plot.getTimeMax(),
plot.getTimePadding(),
plot.getNonTimeMaxPadding(),
plot.getNonTimeMinPadding(),
plot.useOrdinalPositionForSubplots(),
plot.getTimeAxisUserPin().isPinned(),
plot.getPlotLineDraw(),
plot.getPlotLineConnectionType());
}
// Save the panel controls' initial settings to control the Apply and Reset buttons'
// enabled/disabled states.
saveUIControlsSettings();
setupApplyResetListeners();
okButton.setEnabled(false);
refreshDisplay();
}
@SuppressWarnings("serial")
static public class SectionPanel extends JPanel {
public SectionPanel(String titleText, JPanel inputPanel) {
setLayout(new GridBagLayout());
GridBagConstraints gbc = new GridBagConstraints();
gbc.weightx = 1.0;
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.gridwidth = GridBagConstraints.REMAINDER;
setBorder(BorderFactory.createTitledBorder(titleText));
add(inputPanel, gbc);
JLabel padding = new JLabel();
gbc.weighty = 1.0;
add(padding, gbc);
}
}
/*
* Take a snapshot of the UI controls' settings. ("ss" = saved setting)
* For button groups, only the selected button needs to be recorded.
* For spinners, the displayed text is recorded.
*/
private void saveUIControlsSettings() {
// Time system drop-down box - currently has only one possible value
// Choice of axis for Time
ssWhichAxisAsTime = findSelectedButton(xAxisAsTimeRadioButton, yAxisAsTimeRadioButton);
// X-axis orientation
ssXMaxAtWhich = findSelectedButton(xMaxAtRight, xMaxAtLeft);
// Y axis orientation
ssYMaxAtWhich = findSelectedButton(yMaxAtTop, yMaxAtBottom);
// Time Axis Minimums
ssTimeMin = findSelectedButton(timeAxisMinCurrent, timeAxisMinManual, timeAxisMinAuto);
// Time Axis Maximums
ssTimeMax = findSelectedButton(timeAxisMaxCurrent, timeAxisMaxManual, timeAxisMaxAuto);
// Non-Time Axis Minimums
ssNonTimeMin = findSelectedButton(nonTimeAxisMinCurrent, nonTimeAxisMinManual, nonTimeAxisMinAutoAdjust);
// Non-Time Axis Maximums
ssNonTimeMax = findSelectedButton(nonTimeAxisMaxCurrent, nonTimeAxisMaxManual, nonTimeAxisMaxAutoAdjust);
// Panel - Plot Behavior When Space Runs Out
// Time Axis Table
ssTimeAxisMode = findSelectedButton(timeJumpMode, timeScrunchMode);
ssTimeAxisJumpMaxPadding = timeJumpPadding.getText();
ssTimeAxisScrunchMaxPadding = timeScrunchPadding.getText();
ssPinTimeAxis = pinTimeAxis.isSelected();
// Non-Time Axis Table
ssNonTimeMinAxisMode = findSelectedButtons(nonTimeMinAutoAdjustMode, nonTimeMinSemiFixedMode, nonTimeMinFixedMode);
ssNonTimeMaxAxisMode = findSelectedButtons(nonTimeMaxAutoAdjustMode, nonTimeMaxSemiFixedMode, nonTimeMaxFixedMode);
ssNonTimeMinPadding = nonTimeMinPadding.getText();
ssNonTimeMaxPadding = nonTimeMaxPadding.getText();
// Time Axis Manual fields
ssTimeMinManualValue = timeAxisMinManualValue.getValueInMillis();
ssTimeMaxManualValue = timeAxisMaxManualValue.getValueInMillis();
// Non-Time Axis Manual fields
ssNonTimeMinManualValue = nonTimeAxisMinManualValue.getText();
ssNonTimeMaxManualValue = nonTimeAxisMaxManualValue.getText();
// stacked plot grouping
ssGroupByCollection = groupByCollection.isSelected();
// Line drawing options
ssDraw = findSelectedButton(linesOnly, markersAndLines, markersOnly);
ssConnectionLineType = findSelectedButton(direct, step);
}
/*
* Does the Plot Settings Control Panel have pending changes ?
* Compare the values in the ss-variables to the current settings
*/
boolean isPanelDirty() {
JToggleButton selectedButton = null;
// Time system dropdown currently has only one possible selection, so no code is needed yet.
// X or Y Axis As Time
selectedButton = findSelectedButton(xAxisAsTimeRadioButton, yAxisAsTimeRadioButton);
if (ssWhichAxisAsTime != selectedButton) {
return true;
}
// X Axis orientation
selectedButton = findSelectedButton(xMaxAtRight, xMaxAtLeft);
if (ssXMaxAtWhich != selectedButton) {
return true;
}
// Y Axis orientation
selectedButton = findSelectedButton(yMaxAtTop, yMaxAtBottom);
if (ssYMaxAtWhich != selectedButton) {
return true;
}
// Time Axis Minimums
selectedButton = findSelectedButton(timeAxisMinCurrent, timeAxisMinManual, timeAxisMinAuto);
if (ssTimeMin != selectedButton) {
return true;
}
// If the Manual setting was initially selected, check if the Manual value changed
// Note that we convert our time value back to a string to avoid differing evaluations of milliseconds
recycledCalendarA.setTimeInMillis(ssTimeMinManualValue);
if ( (ssTimeMin == timeAxisMinManual && ssTimeMin.getClass().isInstance(timeAxisMinManual)) &&
!dateFormat.format(recycledCalendarA.getTime()).equals(timeAxisMinManualValue.getValue()) ){
return true;
}
// Time Axis Maximums
selectedButton = findSelectedButton(timeAxisMaxCurrent, timeAxisMaxManual, timeAxisMaxAuto);
if (ssTimeMax != selectedButton) {
return true;
}
// If the Manual setting was initially selected, check if the Manual value changed
// Note that we convert our time value back to a string to avoid differing evaluations of milliseconds
recycledCalendarA.setTimeInMillis(ssTimeMaxManualValue);
if ( (ssTimeMax == timeAxisMaxManual && ssTimeMax.getClass().isInstance(timeAxisMaxManual)) &&
!dateFormat.format(recycledCalendarA.getTime()).equals(timeAxisMaxManualValue.getValue()) ) {
return true;
}
// Non-Time Axis Minimums
selectedButton = findSelectedButton(nonTimeAxisMinCurrent, nonTimeAxisMinManual, nonTimeAxisMinAutoAdjust);
if (ssNonTimeMin != selectedButton) {
return true;
}
// If the Manual setting was initially selected, check if the Manual value changed
if (ssNonTimeMin == nonTimeAxisMinManual &&
! ssNonTimeMinManualValue.equals(nonTimeAxisMinManualValue.getText())) {
return true;
}
// Non-Time Axis Maximums
selectedButton = findSelectedButton(nonTimeAxisMaxCurrent, nonTimeAxisMaxManual, nonTimeAxisMaxAutoAdjust);
if (ssNonTimeMax != selectedButton) {
return true;
}
// If the Manual setting was initially selected, check if the Manual value changed
if (ssNonTimeMax == nonTimeAxisMaxManual &&
! ssNonTimeMaxManualValue.equals(nonTimeAxisMaxManualValue.getText())) {
return true;
}
// Panel - Plot Behavior When Space Runs Out
// Time Axis Table
selectedButton = findSelectedButton(timeJumpMode, timeScrunchMode);
if (ssTimeAxisMode != selectedButton) {
return true;
}
if (! ssTimeAxisJumpMaxPadding.equals(timeJumpPadding.getText())) {
return true;
}
if (! ssTimeAxisScrunchMaxPadding.equals(timeScrunchPadding.getText())) {
return true;
}
if (!ssPinTimeAxis.equals(pinTimeAxis.isSelected())) {
return true;
}
// Non-Time Axis Table
if (!buttonStateMatch(findSelectedButtons(nonTimeMinAutoAdjustMode, nonTimeMinSemiFixedMode, nonTimeMinFixedMode),
ssNonTimeMinAxisMode)) {
return true;
}
if (!buttonStateMatch(findSelectedButtons(nonTimeMaxAutoAdjustMode, nonTimeMaxSemiFixedMode, nonTimeMaxFixedMode),
ssNonTimeMaxAxisMode)) {
return true;
}
if (! ssNonTimeMinPadding.equals(nonTimeMinPadding.getText())) {
return true;
}
if (! ssNonTimeMaxPadding.equals(nonTimeMaxPadding.getText())) {
return true;
}
if (ssGroupByCollection != groupByCollection.isSelected()) {
return true;
}
// Line Setup panel: Draw options
selectedButton = findSelectedButton(linesOnly, markersAndLines, markersOnly);
if (ssDraw != selectedButton) {
return true;
}
// Line Setup panel: Connection line type options
selectedButton = findSelectedButton(direct, step);
if (ssConnectionLineType != selectedButton) {
return true;
}
return false;
}
private JToggleButton findSelectedButton( JToggleButton... buttons) {
for ( JToggleButton button : buttons) {
if (button.isSelected()) {
return button;
}
}
logger.error("Unexpected, no selected button in subject group in Plot Settings Control Panel.");
return null;
}
static List<JToggleButton> findSelectedButtons( JToggleButton... buttons) {
List<JToggleButton> selectedButtons = new ArrayList<JToggleButton>(2);
for ( JToggleButton button : buttons) {
if (button.isSelected()) {
selectedButtons.add(button);
}
}
return selectedButtons;
}
/**
* Return true if tw
* @param buttonSet1
* @param buttonSet2
* @return
*/
static boolean buttonStateMatch(List<JToggleButton> buttonSet1, List<JToggleButton> buttonSet2) {
return buttonSet1.size() == buttonSet2.size() &&
buttonSet1.containsAll(buttonSet2);
}
/*
* Add listeners to the UI controls to connect the logic for enabling the
* Apply and Reset buttons
*/
private void setupApplyResetListeners() {
timeDropdown.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
updateMainButtons();
}
});
// Add listener to radio buttons not on the axes
ActionListener buttonListener = new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
updateMainButtons();
}
};
xAxisAsTimeRadioButton.addActionListener(buttonListener);
yAxisAsTimeRadioButton.addActionListener(buttonListener);
xMaxAtRight.addActionListener(buttonListener);
xMaxAtLeft.addActionListener(buttonListener);
yMaxAtTop.addActionListener(buttonListener);
yMaxAtBottom.addActionListener(buttonListener);
timeJumpMode.addActionListener(new TimeAxisModeListener(timeJumpPadding));
timeScrunchMode.addActionListener(new TimeAxisModeListener(timeScrunchPadding));
pinTimeAxis.addActionListener(buttonListener);
nonTimeMinAutoAdjustMode.addActionListener(buttonListener);
nonTimeMinFixedMode.addActionListener(buttonListener);
nonTimeMaxAutoAdjustMode.addActionListener(buttonListener);
nonTimeMaxFixedMode.addActionListener(buttonListener);
// Add listeners to the Time axis buttons
ActionListener timeAxisListener = new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
updateTimeAxisControls();
}
};
timeAxisMinCurrent.addActionListener(timeAxisListener);
timeAxisMinAuto.addActionListener(timeAxisListener);
timeAxisMaxCurrent.addActionListener(timeAxisListener);
timeAxisMaxAuto.addActionListener(timeAxisListener);
timeAxisMinManual.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
timeMinManualHasBeenSelected = true;
updateTimeAxisControls();
}
});
timeAxisMaxManual.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
timeMaxManualHasBeenSelected = true;
updateTimeAxisControls();
}
});
// Add listeners to the Non-Time axis buttons
ActionListener nonTimeAxisListener = new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
updateNonTimeAxisControls();
}
};
nonTimeAxisMinCurrent.addActionListener(nonTimeAxisListener);
nonTimeAxisMinAutoAdjust.addActionListener(nonTimeAxisListener);
nonTimeAxisMaxCurrent.addActionListener(nonTimeAxisListener);
nonTimeAxisMaxAutoAdjust.addActionListener(nonTimeAxisListener);
nonTimeAxisMinManual.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (nonTimeAxisMinManual.isSelected()) {
nonTimeAxisMinManualValue.requestFocusInWindow();
nonTimeAxisMinManualValue.setSelectionStart(0);
String content = nonTimeAxisMinManualValue.getText();
if (content != null) {
nonTimeAxisMinManualValue.setSelectionEnd(content.length());
}
updateNonTimeAxisControls();
}
}
});
nonTimeAxisMaxManual.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (nonTimeAxisMaxManual.isSelected()) {
nonTimeAxisMaxManualValue.requestFocusInWindow();
nonTimeAxisMaxManualValue.setSelectionStart(0);
String content = nonTimeAxisMaxManualValue.getText();
if (content != null) {
nonTimeAxisMaxManualValue.setSelectionEnd(content.length());
}
updateNonTimeAxisControls();
}
}
});
// Add listeners to Non-Time axis text fields
nonTimeSpanValue.addFocusListener(new FocusAdapter() {
@Override
public void focusLost(FocusEvent e) {
if (e.isTemporary())
return;
updateNonTimeAxisControls();
}
});
// Add listeners to Time axis text fields
timeAxisMinManualValue.addFocusListener(new TimeFieldFocusListener(timeAxisMinManual) {
@Override
public void focusGained(FocusEvent e) {
timeMinManualHasBeenSelected = true;
super.focusGained(e);
}
});
timeAxisMaxManualValue.addFocusListener(new TimeFieldFocusListener(timeAxisMaxManual) {
@Override
public void focusGained(FocusEvent e) {
timeMaxManualHasBeenSelected = true;
super.focusGained(e);
}
});
timeSpanValue.addFocusListener(new TimeFieldFocusListener(null));
// Plot Behavior section: Add listeners to Padding text fields
timeJumpPadding.addFocusListener(new TimePaddingFocusListener() {
@Override
public void focusGained(FocusEvent e) {
timeJumpMode.setSelected(true);
}
});
timeScrunchPadding.addFocusListener(new TimePaddingFocusListener() {
@Override
public void focusGained(FocusEvent e) {
timeScrunchMode.setSelected(true);
}
});
FocusListener nontimePaddingListener = new FocusAdapter() {
@Override
public void focusLost(FocusEvent e) {
if (e.isTemporary())
return;
updateNonTimeAxisControls();
}
};
nonTimeMinPadding.addFocusListener(nontimePaddingListener);
nonTimeMaxPadding.addFocusListener(nontimePaddingListener);
}
// Apply and Reset buttons at bottom of the Plot Settings Control Panel
private JPanel createApplyButtonPanel() {
okButton = new JButton(BUNDLE.getString("Apply.label"));
resetButton = new JButton(BUNDLE.getString("Reset.label"));
okButton.setEnabled(false);
resetButton.setEnabled(false);
okButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
setupPlot();
PlotAbstraction plot = plotViewManifestion.getPlot();
if (plot!=null){
setControlPanelState(plot.getAxisOrientationSetting(),
plot.getXAxisMaximumLocation(),
plot.getYAxisMaximumLocation(),
plot.getTimeAxisSubsequentSetting(),
plot.getNonTimeAxisSubsequentMinSetting(),
plot.getNonTimeAxisSubsequentMaxSetting(),
plot.getNonTimeMax(),
plot.getNonTimeMin(),
plot.getTimeMin(),
plot.getTimeMax(),
plot.getTimePadding(),
plot.getNonTimeMaxPadding(),
plot.getNonTimeMinPadding(),
plot.useOrdinalPositionForSubplots(),
plot.getTimeAxisUserPin().isPinned(),
plot.getPlotLineDraw(),
plot.getPlotLineConnectionType());
}
okButton.setEnabled(false);
saveUIControlsSettings();
plotViewManifestion.getManifestedComponent().save();
}
});
resetButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
PlotAbstraction plot = plotViewManifestion.getPlot();
if (plot!=null){
setControlPanelState(plot.getAxisOrientationSetting(),
plot.getXAxisMaximumLocation(),
plot.getYAxisMaximumLocation(),
plot.getTimeAxisSubsequentSetting(),
plot.getNonTimeAxisSubsequentMinSetting(),
plot.getNonTimeAxisSubsequentMaxSetting(),
plot.getNonTimeMax(),
plot.getNonTimeMin(),
plot.getTimeMin(),
plot.getTimeMax(),
plot.getTimePadding(),
plot.getNonTimeMaxPadding(),
plot.getNonTimeMinPadding(),
plot.useOrdinalPositionForSubplots(),
plot.getTimeAxisUserPin().isPinned(),
plot.getPlotLineDraw(),
plot.getPlotLineConnectionType());
}
okButton.setEnabled(false);
resetButton.setEnabled(false);
saveUIControlsSettings();
}
});
JPanel okButtonPadded = new JPanel(new FlowLayout(FlowLayout.CENTER, 10, 7));
okButtonPadded.add(okButton);
okButtonPadded.add(resetButton);
JPanel okPanel = new JPanel();
okPanel.setLayout(new BorderLayout());
okPanel.add(okButtonPadded, BorderLayout.EAST);
// Instrument
okPanel.setName("okPanel");
okButton.setName("okButton");
okButtonPadded.setName("okButtonPadded");
// Set the panel color to a nice shade of gray
okButtonPadded.setOpaque(false);
okPanel.setBackground(OK_PANEL_BACKGROUND_COLOR);
return okPanel;
}
// Assign internal names to the top level class variables
private void instrumentNames() {
timeAxisMinimumsPanel.setName("timeAxisMinimumsPanel");
timeAxisMaximumsPanel.setName("timeAxisMaximumsPanel");
nonTimeAxisMaximumsPanel.setName("nonTimeAxisMaximumsPanel");
nonTimeAxisMinimumsPanel.setName("nonTimeAxisMinimumsPanel");
timeAxisMinAuto.setName("timeAxisMinAuto");
timeAxisMinAutoValue.setName("timeAxisMinAutoValue");
timeAxisMinManual.setName("timeAxisMinManual");
timeAxisMinManualValue.setName("timeAxisMinManualValue");
timeAxisMaxAuto.setName("timeAxisMaxAuto");
timeAxisMaxAutoValue.setName("timeAxisMaxAutoValue");
timeAxisMaxManual.setName("timeAxisMaxManual");
timeAxisMaxManualValue.setName("timeAxisMaxManualValue");
nonTimeAxisMinCurrent.setName("nonTimeAxisMinCurrent");
nonTimeAxisMinCurrentValue.setName("nonTimeAxisMinCurrentValue");
nonTimeAxisMinManual.setName("nonTimeAxisMinManual");
nonTimeAxisMinManualValue.setName("nonTimeAxisMinManualValue");
nonTimeAxisMinAutoAdjust.setName("nonTimeAxisMinAutoAdjust");
nonTimeAxisMaxCurrent.setName("nonTimeAxisMaxCurrent");
nonTimeAxisMaxCurrentValue.setName("nonTimeAxisMaxCurrentValue");
nonTimeAxisMaxManual.setName("nonTimeAxisMaxManual");
nonTimeAxisMaxManualValue.setName("nonTimeAxisMaxManualValue");
nonTimeAxisMaxAutoAdjust.setName("nonTimeAxisMaxAutoAdjust");
timeJumpMode.setName("timeJumpMode");
timeScrunchMode.setName("timeScrunchMode");
timeJumpPadding.setName("timeJumpPadding");
timeScrunchPadding.setName("timeScrunchPadding");
nonTimeMinAutoAdjustMode.setName("nonTimeMinAutoAdjustMode");
nonTimeMaxAutoAdjustMode.setName("nonTimeMaxAutoAdjustMode");
nonTimeMinFixedMode.setName("nonTimeMinFixedMode");
nonTimeMaxFixedMode.setName("nonTimeMaxFixedMode");
nonTimeMinSemiFixedMode.setName("nonTimeMinSemiFixedMode");
nonTimeMaxSemiFixedMode.setName("nonTimeMaxSemiFixedMode");
imagePanel.setName("imagePanel");
timeDropdown.setName("timeDropdown");
timeSpanValue.setName("timeSpanValue");
nonTimeSpanValue.setName("nonTimeSpanValue");
xMinLabel.setName("xMinLabel");
xMaxLabel.setName("xMaxLabel");
xAxisAsTimeRadioButton.setName("xAxisAsTimeRadioButton");
yAxisAsTimeRadioButton.setName("yAxisAsTimeRadioButton");
xMaxAtRight.setName("xMaxAtRight");
xMaxAtLeft.setName("xMaxAtLeft");
yMaxAtTop.setName("yMaxAtTop");
yMaxAtBottom.setName("yMaxAtBottom");
yAxisType.setName("yAxisType");
xAxisType.setName("xAxisType");
xAxisSpanCluster.setName("xAxisSpanCluster");
xAxisAdjacentPanel.setName("xAxisAdjacentPanel");
xAxisButtonsPanel.setName("xAxisButtonsPanel");
yAxisSpanPanel.setName("ySpanPanel");
yMaximumsPlusPanel.setName("yMaximumsPlusPanel");
yMinimumsPlusPanel.setName("yMinimumsPlusPanel");
yAxisButtonsPanel.setName("yAxisButtonsPanel");
}
/**
* This method scans and sets the Time Axis controls next to the static plot image.
* Triggered by time axis button selection.
*/
GregorianCalendar scratchCalendar = new GregorianCalendar();
GregorianCalendar workCalendar = new GregorianCalendar();
{
workCalendar.setTimeZone(TimeZone.getTimeZone(PlotConstants.DEFAULT_TIME_ZONE));
}
void updateTimeAxisControls() {
// Enable/disable the Span control
timeSpanValue.setEnabled(timeAxisMaxAuto.isSelected());
// Set the value of the Time Span field and the various Min and Max Time fields
if (timeAxisMinAuto.isSelected() && timeAxisMaxAuto.isSelected()) {
// If both Auto buttons are selected, Span value is used
scratchCalendar.setTimeInMillis(timeAxisMinAutoValue.getTimeInMillis());
scratchCalendar.add(Calendar.SECOND, timeSpanValue.getSecond());
scratchCalendar.add(Calendar.MINUTE, timeSpanValue.getMinute());
scratchCalendar.add(Calendar.HOUR_OF_DAY, timeSpanValue.getHourOfDay());
scratchCalendar.add(Calendar.DAY_OF_YEAR, timeSpanValue.getDayOfYear());
timeAxisMaxAutoValue.setTime(scratchCalendar);
} else if (timeAxisMinAuto.isSelected() && timeAxisMaxManual.isSelected()) {
/*
* Min Auto ("Now"), and Max Manual
*/
timeSpanValue.setTime(subtractTimes(timeAxisMinAutoValue.getTimeInMillis(),
timeAxisMaxManualValue.getValueInMillis()));
} else if (timeAxisMinAuto.isSelected() && timeAxisMaxCurrent.isSelected()) {
/*
* Min Auto ("Now"), and Current Max
*/
timeSpanValue.setTime(subtractTimes(timeAxisMinAutoValue.getTimeInMillis(),
timeAxisMaxCurrentValue.getTimeInMillis()));
} else if (timeAxisMinManual.isSelected() && timeAxisMaxAuto.isSelected()) {
/*
* Min Manual, and Max Auto ("Min+Span")
*/
scratchCalendar.setTimeInMillis(timeAxisMinManualValue.getValueInMillis());
scratchCalendar.add(Calendar.SECOND, timeSpanValue.getSecond());
scratchCalendar.add(Calendar.MINUTE, timeSpanValue.getMinute());
scratchCalendar.add(Calendar.HOUR_OF_DAY, timeSpanValue.getHourOfDay());
scratchCalendar.add(Calendar.DAY_OF_YEAR, timeSpanValue.getDayOfYear());
timeAxisMaxAutoValue.setTime(scratchCalendar);
} else if (timeAxisMinManual.isSelected() && timeAxisMaxManual.isSelected()) {
/*
* Min Manual, and Max Manual
* - subtract the Min Manual from the Max Manual to get the new Span value
*/
timeSpanValue.setTime(subtractTimes(timeAxisMinManualValue.getValueInMillis(),
timeAxisMaxManualValue.getValueInMillis()));
} else if (timeAxisMinManual.isSelected() && timeAxisMaxCurrent.isSelected()) {
/*
* Min Manual, and Current Max
* - subtract the Min Manual from the Current Max to get the new Span value
*/
timeSpanValue.setTime(subtractTimes(timeAxisMinManualValue.getValueInMillis(),
timeAxisMaxCurrentValue.getTimeInMillis()));
} else if (timeAxisMinCurrent.isSelected() && timeAxisMaxAuto.isSelected()) {
/*
* Current Min, and Max Auto ("Min+Span")
* - set the Max Auto value to the sum of Current Min and the Span value
*/
scratchCalendar.setTimeInMillis(timeAxisMinCurrentValue.getTimeInMillis());
scratchCalendar.add(Calendar.SECOND, timeSpanValue.getSecond());
scratchCalendar.add(Calendar.MINUTE, timeSpanValue.getMinute());
scratchCalendar.add(Calendar.HOUR_OF_DAY, timeSpanValue.getHourOfDay());
scratchCalendar.add(Calendar.DAY_OF_YEAR, timeSpanValue.getDayOfYear());
timeAxisMaxAutoValue.setTime(scratchCalendar);
} else if (timeAxisMinCurrent.isSelected() && timeAxisMaxManual.isSelected()) {
/*
* Current Min, and Max Manual
* - subtract the Current Min from Max Manual to get the new Span value
*/
timeSpanValue.setTime(subtractTimes(timeAxisMinCurrentValue.getTimeInMillis(),
timeAxisMaxManualValue.getValueInMillis()));
} else if (timeAxisMinCurrent.isSelected() && timeAxisMaxCurrent.isSelected()) {
/*
* Current Min, and Current Max
* - subtract the Current Min from the Current Max to get the new Span value
*/
timeSpanValue.setTime(subtractTimes(timeAxisMinCurrentValue.getTimeInMillis(),
timeAxisMaxCurrentValue.getTimeInMillis()));
} else {
logger.error("Program issue: if-else cases are missing one use case.");
}
if (timeAxisMinCurrent.isSelected()) {
scratchCalendar.setTimeInMillis(timeAxisMinCurrentValue.getTimeInMillis());
} else
if (timeAxisMinManual.isSelected()) {
scratchCalendar.setTimeInMillis(timeAxisMinManualValue.getValueInMillis());
} else
if (timeAxisMinAuto.isSelected()) {
scratchCalendar.setTimeInMillis(timeAxisMinAutoValue.getTimeInMillis());
}
scratchCalendar.add(Calendar.SECOND, timeSpanValue.getSecond());
scratchCalendar.add(Calendar.MINUTE, timeSpanValue.getMinute());
scratchCalendar.add(Calendar.HOUR_OF_DAY, timeSpanValue.getHourOfDay());
scratchCalendar.add(Calendar.DAY_OF_YEAR, timeSpanValue.getDayOfYear());
timeAxisMaxAutoValue.setTime(scratchCalendar);
// Update the Time axis Current Min and Max values
GregorianCalendar plotMinTime = plotViewManifestion.getPlot().getMinTime();
GregorianCalendar plotMaxTime = plotViewManifestion.getPlot().getMaxTime();
timeAxisMinCurrentValue.setTime(plotMinTime);
timeAxisMaxCurrentValue.setTime(plotMaxTime);
// If the Manual (Min and Max) fields have NOT been selected up to now, update them with the
// plot's current Min and Max values
if (! timeMinManualHasBeenSelected) {
workCalendar.setTime(plotMinTime.getTime());
timeAxisMinManualValue.setTime(workCalendar);
}
if (! timeMaxManualHasBeenSelected) {
workCalendar.setTime(plotMaxTime.getTime());
timeAxisMaxManualValue.setTime(workCalendar);
}
updateMainButtons();
}
/**
* Returns the difference between two times as a time Duration
* @param begin
* @param end
* @return
*/
private TimeDuration subtractTimes(long begin, long end) {
if (begin < end) {
long difference = end - begin;
long days = difference / (24 * 60 * 60 * 1000);
long remainder = difference - (days * 24 * 60 * 60 * 1000);
long hours = remainder / (60 * 60 * 1000);
remainder = remainder - (hours * 60 * 60 * 1000);
long minutes = remainder / (60 * 1000);
remainder = remainder - (minutes * 60 * 1000);
long seconds = remainder / (1000);
return new TimeDuration((int) days, (int) hours, (int) minutes, (int) seconds);
} else {
return new TimeDuration(0, 0, 0, 0);
}
}
/**
* This method scans and sets the Non-Time Axis controls next to the static plot image.
* Triggered when a non-time radio button is selected or on update tick
*/
void updateNonTimeAxisControls() {
assert !(nonTimeAxisMinAutoAdjust.isSelected() && nonTimeAxisMaxAutoAdjust.isSelected()) : "Illegal condition: Both span radio buttons are selected.";
// Enable/disable the non-time Span value
if (nonTimeAxisMinAutoAdjust.isSelected() || nonTimeAxisMaxAutoAdjust.isSelected()) {
nonTimeSpanValue.setEnabled(true);
} else {
nonTimeSpanValue.setEnabled(false);
}
// Enable/disable the non-time Auto-Adjust (Span-dependent) controls
if (nonTimeAxisMaxAutoAdjust.isSelected()) {
nonTimeAxisMinAutoAdjust.setEnabled(false);
nonTimeAxisMinAutoAdjustValue.setEnabled(false);
} else
if (nonTimeAxisMinAutoAdjust.isSelected()) {
nonTimeAxisMaxAutoAdjust.setEnabled(false);
nonTimeAxisMaxAutoAdjustValue.setEnabled(false);
} else
// If neither of the buttons using Span is selected, enable both
if (!nonTimeAxisMinAutoAdjust.isSelected() && !nonTimeAxisMaxAutoAdjust.isSelected()) {
nonTimeAxisMinAutoAdjust.setEnabled(true);
nonTimeAxisMaxAutoAdjust.setEnabled(true);
nonTimeAxisMinAutoAdjustValue.setEnabled(true);
nonTimeAxisMaxAutoAdjustValue.setEnabled(true);
}
// Update the Span-dependent controls
// nonTimeAxisMinAutoAdjustValue: (Max - Span)
double maxValue = getNonTimeMaxValue();
// nonTimeAxisMaxAutoAdjustValue: (Min + Span)
double minValue = getNonTimeMinValue();
try {
String span = nonTimeSpanValue.getText();
if (! span.isEmpty()) {
double spanValue = nonTimeSpanValue.getDoubleValue();
nonTimeAxisMinAutoAdjustValue.setValue(maxValue - spanValue);
nonTimeAxisMaxAutoAdjustValue.setValue(minValue + spanValue);
}
} catch (ParseException e) {
logger.error("Plot control panel: Could not parse non-time span value.");
}
if (!(nonTimeAxisMinAutoAdjust.isSelected() || nonTimeAxisMaxAutoAdjust.isSelected())) {
double difference = getNonTimeMaxValue() - getNonTimeMinValue();
nonTimeSpanValue.setValue(difference);
}
updateMainButtons();
}
private boolean isValidTimeAxisValues() {
GregorianCalendar gc = new GregorianCalendar();
gc.setTimeInMillis(plotViewManifestion.getCurrentMCTTime());
// If the time from MCT is invalid, then we do not evaluate Time Span
if (gc.get(Calendar.YEAR) <= 1970) {
return true;
}
if (timeAxisMinCurrent.isSelected() && timeAxisMaxCurrent.isSelected()
&& timeSpanValue.getText().equals("000/00:00:00") ) {
return true;
}
// For valid MCT times, evaluate the value in Time Span
return timeSpanValue.getSubYearValue() > 0;
}
private boolean isValidNonTimeAxisValues() {
try {
if (nonTimeSpanValue.getText().isEmpty()) {
return false;
}
// When the plot has no data, the current min and max may be the same value,
// usually zero. This should not disable the Apply and Reset buttons.
if (nonTimeAxisMinCurrent.isSelected() && nonTimeAxisMaxCurrent.isSelected()
&& nonTimeSpanValue.getDoubleValue() == 0.0 ) {
return true;
}
// If the plot has data, then check that the Span value is greater than zero.
if (nonTimeSpanValue.getDoubleValue() <= 0.0) {
return false;
}
} catch (ParseException e) {
logger.error("Could not parse the non-time span's value");
}
return true;
}
/**
* This method checks the values in the axis controls and then enables/disables the
* Apply button.
* @param isPanelDirty
*/
private void updateMainButtons() {
// Apply button enable/disable.
if (isPanelDirty() && isValidTimeAxisValues() && isValidNonTimeAxisValues()) {
okButton.setEnabled(true);
okButton.setToolTipText(BUNDLE.getString("ApplyPanelSettingToPlot.label"));
resetButton.setEnabled(true);
resetButton.setToolTipText(BUNDLE.getString("ResetPanelSettingToMatchPlot.label"));
} else {
okButton.setEnabled(false);
// Set tool tip to explain why the control is disabled.
StringBuilder toolTip = new StringBuilder("<HTML>" + BUNDLE.getString("ApplyButtonIsInActive.label") + ":<BR>");
if (!isPanelDirty()) {
toolTip.append(BUNDLE.getString("NoChangedMadeToPanel.label") + "<BR>");
}
if(!isValidTimeAxisValues()) {
toolTip.append(BUNDLE.getString("TimeAxisValuesInvalid.label") + "<BR>");
}
if(!isValidNonTimeAxisValues()) {
toolTip.append(BUNDLE.getString("NonTimeAxisValuesInvalid.label") + "<BR>");
}
toolTip.append("</HTML>");
okButton.setToolTipText(toolTip.toString());
resetButton.setEnabled(false);
resetButton.setToolTipText(BUNDLE.getString("ResetButtonInactiveBecauseNoChangesMade.label"));
}
}
/**
* Update the label representing the time axis' Min + Span value
* Selections are: Min Manual button, Max Auto ("Min + Span") button
*/
public void refreshDisplay() {
// Update the MCT time ("Now")
GregorianCalendar gc = new GregorianCalendar();
gc.setTimeInMillis(plotViewManifestion.getCurrentMCTTime());
timeAxisMinAutoValue.setTime(gc);
// Update the time min/max values
nonTimeAxisMinCurrentValue.setValue(plotViewManifestion.getMinFeedValue());
nonTimeAxisMaxCurrentValue.setValue(plotViewManifestion.getMaxFeedValue());
updateTimeAxisControls();
updateNonTimeAxisControls();
}
// Initially returns float; but shouldn't this be double precision (?)
double getNonTimeMaxValue() {
if (nonTimeAxisMaxCurrent.isSelected()) {
return nonTimeAxisMaxCurrentValue.getValue().floatValue();
} else if (nonTimeAxisMaxManual.isSelected()) {
//float result = 0;
double result = 1.0;
try {
result = nonTimeAxisMaxManualValue.getDoubleValue().floatValue();
} catch (ParseException e) {
logger.error("Plot control panel: Could not read the non-time axis' maximum manual value");
}
return result;
} else if (nonTimeAxisMaxAutoAdjust.isSelected()) {
return nonTimeAxisMaxAutoAdjustValue.getValue().floatValue();
}
return 1.0;
}
double getNonTimeMinValue() {
if (nonTimeAxisMinCurrent.isSelected()) {
return nonTimeAxisMinCurrentValue.getValue().floatValue();
} else if (nonTimeAxisMinManual.isSelected()) {
double result = 0.0;
try {
result = nonTimeAxisMinManualValue.getDoubleValue().floatValue();
} catch (ParseException e) {
logger.error("Plot control panel: Could not read the non-time axis' minimum manual value");
}
return result;
} else if (nonTimeAxisMinAutoAdjust.isSelected()) {
return nonTimeAxisMinAutoAdjustValue.getValue().floatValue();
}
return 0.0;
}
/**
* Gets the PlotViewManifestation associated with this control panel.
* @return the PlotViewManifesation
*/
public PlotViewManifestation getPlot() {
return plotViewManifestion;
}
// The Initial Settings panel
// Name change: Initial Settings is now labeled Min/Max Setup
private JPanel getInitialSetupPanel() {
JPanel initialSetup = new JPanel();
initialSetup.setLayout(new BoxLayout(initialSetup, BoxLayout.Y_AXIS));
initialSetup.setBorder(SETUP_AND_BEHAVIOR_MARGINS);
yAxisType = new JLabel("(NON-TIME)");
JPanel yAxisTypePanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 0, 0));
yAxisTypePanel.add(yAxisType);
imagePanel = new StillPlotImagePanel();
// Start defining the top panel
JPanel initTopPanel = createTopPanel();
// Assemble the bottom panel
JPanel initBottomPanel = new JPanel();
initBottomPanel.setLayout(new GridBagLayout());
initBottomPanel.setBorder(TOP_PADDED_MARGINS);
JPanel yAxisPanelSet = createYAxisPanelSet();
JPanel xAxisPanelSet = createXAxisPanelSet();
JPanel yAxisControlsPanel = new JPanel();
yAxisControlsPanel.setLayout(new BoxLayout(yAxisControlsPanel, BoxLayout.Y_AXIS));
yAxisPanelSet.setAlignmentX(Component.CENTER_ALIGNMENT);
yAxisControlsPanel.add(yAxisPanelSet);
JPanel xAxisControlsPanel = new JPanel(new GridLayout(1, 1));
xAxisControlsPanel.add(xAxisPanelSet);
// The title label for (TIME) or (NON-TIME)
GridBagConstraints gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = 0;
gbc.fill = GridBagConstraints.BOTH;
initBottomPanel.add(yAxisTypePanel, gbc);
// The Y Axis controls panel
GridBagConstraints gbc1 = new GridBagConstraints();
gbc1.gridx = 0;
gbc1.gridy = 1;
gbc1.gridwidth = 1;
gbc1.gridheight = 3;
gbc1.fill = GridBagConstraints.BOTH;
// To align the "Min" or "Max" label with the bottom of the static plot image,
// add a vertical shim under the Y Axis bottom button set and "Min"/"Max" label.
gbc1.insets = new Insets(2, 0, 10, 2);
initBottomPanel.add(yAxisControlsPanel, gbc1);
// The static plot image
GridBagConstraints gbc2 = new GridBagConstraints();
gbc2.gridx = 1;
gbc2.gridy = 1;
gbc2.gridwidth = 3;
gbc2.gridheight = 3;
initBottomPanel.add(imagePanel, gbc2);
// The X Axis controls panel
GridBagConstraints gbc3 = new GridBagConstraints();
gbc3.gridx = 1;
gbc3.gridy = 4;
gbc3.gridwidth = 3;
gbc3.gridheight = 1;
gbc3.fill = GridBagConstraints.BOTH;
gbc3.insets = new Insets(0, 8, 0, 0);
initBottomPanel.add(xAxisControlsPanel, gbc3);
// Assemble the major panel: Initial Settings
JPanel topClamp = new JPanel(new BorderLayout());
topClamp.add(initTopPanel, BorderLayout.NORTH);
JPanel bottomClamp = new JPanel(new BorderLayout());
bottomClamp.add(initBottomPanel, BorderLayout.NORTH);
JPanel sideClamp = new JPanel(new BorderLayout());
sideClamp.add(bottomClamp, BorderLayout.WEST);
initialSetup.add(Box.createRigidArea(new Dimension(0, INNER_PADDING)));
initialSetup.add(topClamp);
initialSetup.add(Box.createRigidArea(new Dimension(0, INNER_PADDING)));
initialSetup.add(new JSeparator());
initialSetup.add(sideClamp);
// Instrument
initialSetup.setName("initialSetup");
initTopPanel.setName("initTopPanel");
initBottomPanel.setName("initBottomPanel");
yAxisPanelSet.setName("yAxisPanelSet");
xAxisPanelSet.setName("xAxisPanelSet");
yAxisControlsPanel.setName("yAxisInnerPanel");
xAxisControlsPanel.setName("nontimeSidePanel");
topClamp.setName("topClamp");
bottomClamp.setName("bottomClamp");
return initialSetup;
}
// Top panel that controls which axis plots Time and the direction of each axis
private JPanel createTopPanel() {
JPanel initTopPanel = new JPanel();
initTopPanel.setLayout(new GridBagLayout());
// Left column
timeDropdown = new JComboBox( new Object[]{BUNDLE.getString("GMT.label")});
JPanel timenessRow = new JPanel();
timenessRow.add(new JLabel(BUNDLE.getString("Time.label")));
timenessRow.add(timeDropdown);
xAxisAsTimeRadioButton = new JRadioButton(BUNDLE.getString("XAxisAsTime.label"));
yAxisAsTimeRadioButton = new JRadioButton(BUNDLE.getString("YAxisAsTime.label"));
// Middle column
JLabel xDirTitle = new JLabel(BUNDLE.getString("XAxis.label"));
xMaxAtRight = new JRadioButton(BUNDLE.getString("MaxAtRight.label"));
xMaxAtLeft = new JRadioButton(BUNDLE.getString("MaxAtLeft.label"));
// Right column
JLabel yDirTitle = new JLabel(BUNDLE.getString("YAxis.label"));
yMaxAtTop = new JRadioButton(BUNDLE.getString("MaxAtTop.label"));
yMaxAtBottom = new JRadioButton(BUNDLE.getString("MaxAtBottom.label"));
// Separator lines for the top panel
JSeparator separator1 = new JSeparator(SwingConstants.VERTICAL);
JSeparator separator2 = new JSeparator(SwingConstants.VERTICAL);
// Assemble the top row of cells (combo box, 2 separators and 2 titles)
GridBagConstraints gbcTopA = new GridBagConstraints();
gbcTopA.anchor = GridBagConstraints.WEST;
initTopPanel.add(timenessRow, gbcTopA);
GridBagConstraints gbcSep1 = new GridBagConstraints();
gbcSep1.gridheight = 3;
gbcSep1.fill = GridBagConstraints.BOTH;
gbcSep1.insets = new Insets(0, 5, 0, 5);
initTopPanel.add(separator1, gbcSep1);
GridBagConstraints gbcTopB = new GridBagConstraints();
gbcTopB.anchor = GridBagConstraints.WEST;
gbcTopB.insets = new Insets(0, 4, 0, 0);
initTopPanel.add(xDirTitle, gbcTopB);
initTopPanel.add(separator2, gbcSep1);
initTopPanel.add(yDirTitle, gbcTopB);
GridBagConstraints gbc = new GridBagConstraints();
gbc.anchor = GridBagConstraints.WEST;
gbc.gridy = 1;
gbc.gridx = 0;
initTopPanel.add(xAxisAsTimeRadioButton, gbc);
gbc.gridx = 2;
initTopPanel.add(xMaxAtRight, gbc);
gbc.gridx = 4;
initTopPanel.add(yMaxAtTop, gbc);
gbc.gridy = 2;
gbc.gridx = 0;
gbc.insets = new Insets(5, 0, 0, 0);
initTopPanel.add(yAxisAsTimeRadioButton, gbc);
gbc.gridx = 2;
initTopPanel.add(xMaxAtLeft, gbc);
gbc.gridx = 4;
initTopPanel.add(yMaxAtBottom, gbc);
// add stacked plot grouping
GridBagConstraints groupingGbc = new GridBagConstraints();
groupingGbc.gridheight = 3;
groupingGbc.fill = GridBagConstraints.BOTH;
groupingGbc.insets = new Insets(0, 5, 0, 5);
initTopPanel.add(new JSeparator(JSeparator.VERTICAL), groupingGbc);
// Stacked Plot Grouping Label
groupingGbc.gridheight = 1;
groupingGbc.gridy = 0;
initTopPanel.add(new JLabel(BUNDLE.getString("StackedPlotGroping.label")),groupingGbc);
groupingGbc.gridy = 1;
groupByCollection = new JCheckBox(BUNDLE.getString("GroupByCollection.label"));
groupByCollection.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
updateMainButtons();
}
});
initTopPanel.add(groupByCollection,groupingGbc);
// Add listeners and set initial state
addTopPanelListenersAndState();
// Instrument
initTopPanel.setName("initTopPanel");
timenessRow.setName("timenessRow");
JPanel horizontalSqueeze = new JPanel(new BorderLayout());
horizontalSqueeze.add(initTopPanel, BorderLayout.WEST);
return horizontalSqueeze;
}
private void addTopPanelListenersAndState() {
xAxisAsTimeRadioButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
xAxisAsTimeRadioButtonActionPerformed();
}
});
yAxisAsTimeRadioButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
yAxisAsTimeRadioButtonActionPerformed();
}
});
xMaxAtRight.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
xMaxAtRightActionPerformed();
}
});
xMaxAtLeft.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
xMaxAtLeftActionPerformed();
}
});
yMaxAtTop.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
yMaxAtTopActionPerformed();
}
});
yMaxAtBottom.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
yMaxAtBottomActionPerformed();
}
});
xAxisAsTimeRadioButton.setSelected(true);
xMaxAtRight.setSelected(true);
yMaxAtTop.setSelected(true);
// Button Groups
ButtonGroup timenessGroup = new ButtonGroup();
timenessGroup.add(xAxisAsTimeRadioButton);
timenessGroup.add(yAxisAsTimeRadioButton);
ButtonGroup xDirectionGroup = new ButtonGroup();
xDirectionGroup.add(xMaxAtRight);
xDirectionGroup.add(xMaxAtLeft);
ButtonGroup yDirectionGroup = new ButtonGroup();
yDirectionGroup.add(yMaxAtTop);
yDirectionGroup.add(yMaxAtBottom);
}
private void xAxisAsTimeRadioButtonActionPerformed() {
// Move the time axis panels to the x axis class
// Move the nontime axis panels to the y axis class
xAxisButtonsPanel.insertMinMaxPanels(timeAxisMinimumsPanel, timeAxisMaximumsPanel);
yAxisButtonsPanel.insertMinMaxPanels(nonTimeAxisMinimumsPanel, nonTimeAxisMaximumsPanel);
xAxisSpanCluster.setSpanField(timeSpanValue); //Panel);
yAxisSpanPanel.setSpanField(nonTimeSpanValue);
if (yMaxAtTop.isSelected()) {
yAxisButtonsPanel.setNormalOrder(true);
} else {
yAxisButtonsPanel.setNormalOrder(false);
}
if (xMaxAtRight.isSelected()) {
xMaxAtRight.doClick();
} else {
xMaxAtLeft.doClick();
}
xAxisType.setText("(" + BUNDLE.getString("Time.label") + ")");
yAxisType.setText("(" + BUNDLE.getString("NonTime.label") + ")");
imagePanel.setImageToTimeOnXAxis(xMaxAtRight.isSelected());
behaviorTimeAxisLetter.setText(BUNDLE.getString("X.label"));
behaviorNonTimeAxisLetter.setText(BUNDLE.getString("Y.label"));
}
private void yAxisAsTimeRadioButtonActionPerformed() {
xAxisButtonsPanel.insertMinMaxPanels(nonTimeAxisMinimumsPanel, nonTimeAxisMaximumsPanel);
yAxisButtonsPanel.insertMinMaxPanels(timeAxisMinimumsPanel, timeAxisMaximumsPanel);
xAxisSpanCluster.setSpanField(nonTimeSpanValue);
yAxisSpanPanel.setSpanField(timeSpanValue); //Panel);
if (yMaxAtTop.isSelected()) {
yAxisButtonsPanel.setNormalOrder(true);
} else {
yAxisButtonsPanel.setNormalOrder(false);
}
if (xMaxAtRight.isSelected()) {
xMaxAtRight.doClick();
} else {
xMaxAtLeft.doClick();
}
xAxisType.setText("(" + BUNDLE.getString("NonTime.label") + ")");
yAxisType.setText("(" + BUNDLE.getString("Time.label") + ")");
imagePanel.setImageToTimeOnYAxis(yMaxAtTop.isSelected());
behaviorTimeAxisLetter.setText(BUNDLE.getString("Y.label"));
behaviorNonTimeAxisLetter.setText(BUNDLE.getString("X.label"));
}
private void xMaxAtRightActionPerformed() {
xAxisAdjacentPanel.setNormalOrder(true);
xAxisButtonsPanel.setNormalOrder(true);
if (xAxisAsTimeRadioButton.isSelected()) {
imagePanel.setImageToTimeOnXAxis(true); // normal direction
}
}
private void xMaxAtLeftActionPerformed() {
xAxisAdjacentPanel.setNormalOrder(false);
xAxisButtonsPanel.setNormalOrder(false);
if (xAxisAsTimeRadioButton.isSelected()) {
imagePanel.setImageToTimeOnXAxis(false); // reverse direction
}
}
private void yMaxAtTopActionPerformed() {
yAxisButtonsPanel.setNormalOrder(true);
if (yAxisAsTimeRadioButton.isSelected()) {
imagePanel.setImageToTimeOnYAxis(true); // normal direction
}
}
private void yMaxAtBottomActionPerformed() {
yAxisButtonsPanel.setNormalOrder(false);
if (yAxisAsTimeRadioButton.isSelected()) {
imagePanel.setImageToTimeOnYAxis(false); // reverse direction
}
}
// The controls that exactly align with the X axis
private JPanel createXAxisPanelSet() {
xAxisSpanCluster = new XAxisSpanCluster();
xAxisAdjacentPanel = new XAxisAdjacentPanel();
xAxisAdjacentPanel.setNormalOrder(true);
xAxisButtonsPanel = new XAxisButtonsPanel();
timeAxisMinimumsPanel = new TimeAxisMinimumsPanel();
timeAxisMaximumsPanel = new TimeAxisMaximumsPanel();
xAxisButtonsPanel.insertMinMaxPanels(timeAxisMinimumsPanel, timeAxisMaximumsPanel);
xAxisButtonsPanel.setNormalOrder(true);
JPanel belowXAxisPanel = new JPanel();
belowXAxisPanel.setLayout(new BoxLayout(belowXAxisPanel, BoxLayout.Y_AXIS));
belowXAxisPanel.add(xAxisAdjacentPanel);
belowXAxisPanel.add(xAxisButtonsPanel);
belowXAxisPanel.add(Box.createVerticalStrut(X_AXIS_TYPE_VERTICAL_SPACING));
xAxisType = new JLabel("(TIME)");
belowXAxisPanel.add(xAxisType);
xAxisType.setAlignmentX(Component.CENTER_ALIGNMENT);
// Instrument
belowXAxisPanel.setName("belowXAxisPanel");
return belowXAxisPanel;
}
// The controls that exactly align with the Y axis
private JPanel createYAxisPanelSet() {
yMaximumsPlusPanel = new YMaximumsPlusPanel();
yAxisSpanPanel = new YAxisSpanPanel();
yMinimumsPlusPanel = new YMinimumsPlusPanel();
yAxisButtonsPanel = new YAxisButtonsPanel();
yAxisButtonsPanel.insertMinMaxPanels(nonTimeAxisMinimumsPanel, nonTimeAxisMaximumsPanel);
yAxisButtonsPanel.setNormalOrder(true);
return yAxisButtonsPanel;
}
// Convenience method for populating and applying a standard layout for multi-item rows
private JPanel createMultiItemRow(JRadioButton button, JComponent secondItem) {
JPanel panel = new JPanel();
panel.setLayout(new GridBagLayout());
GridBagConstraints gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.anchor = GridBagConstraints.BASELINE_LEADING;
if (button != null) {
button.setSelected(false);
panel.add(button, gbc);
}
if (secondItem != null) {
gbc.gridx = 1;
gbc.insets = new Insets(0, SPACE_BETWEEN_ROW_ITEMS, 0, 0);
gbc.weightx = 1;
panel.add(secondItem, gbc);
}
panel.setName("multiItemRow");
return panel;
}
// The Plot Behavior panel
private JPanel getPlotBehaviorPanel() {
JPanel plotBehavior = new JPanel();
plotBehavior.setLayout(new GridBagLayout());
plotBehavior.setBorder(SETUP_AND_BEHAVIOR_MARGINS);
JPanel modePanel = new JPanel(new GridLayout(1, 1));
JButton bMode = new JButton(BUNDLE.getString("Mode.label"));
bMode.setAlignmentY(CENTER_ALIGNMENT);
modePanel.add(bMode);
JPanel minPanel = new JPanel(new GridLayout(1, 1));
JLabel bMin = new JLabel(BUNDLE.getString("Min.label"));
bMin.setHorizontalAlignment(JLabel.CENTER);
minPanel.add(bMin);
JPanel maxPanel = new JPanel(new GridLayout(1, 1));
maxPanel.add(new JLabel(BUNDLE.getString("Max.label")));
GridLinedPanel timeAxisPanel = createGriddedTimeAxisPanel();
GridLinedPanel nonTimeAxisPanel = createGriddedNonTimeAxisPanel();
behaviorTimeAxisLetter = new JLabel("_");
JPanel behaviorTimeTitlePanel = new JPanel();
behaviorTimeTitlePanel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, NONTIME_TITLE_SPACING));
behaviorTimeTitlePanel.add(new JLabel(BUNDLE.getString("TimeAxis.label") + " ("));
behaviorTimeTitlePanel.add(behaviorTimeAxisLetter);
behaviorTimeTitlePanel.add(new JLabel("):"));
pinTimeAxis = new JCheckBox(BUNDLE.getString("PinTimeAxis.label"));
behaviorTimeTitlePanel.add(pinTimeAxis);
behaviorNonTimeAxisLetter = new JLabel("_");
JPanel behaviorNonTimeTitlePanel = new JPanel();
behaviorNonTimeTitlePanel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, NONTIME_TITLE_SPACING));
behaviorNonTimeTitlePanel.add(new JLabel(BUNDLE.getString("NonTimeAxis.label") + " ("));
behaviorNonTimeTitlePanel.add(behaviorNonTimeAxisLetter);
behaviorNonTimeTitlePanel.add(new JLabel("):"));
GridBagConstraints gbc = new GridBagConstraints();
gbc.anchor = GridBagConstraints.WEST;
gbc.gridx = 0;
gbc.gridy = 0;
gbc.insets = new Insets(6, 0, 0, 0);
plotBehavior.add(behaviorTimeTitlePanel, gbc);
gbc.gridy++;
gbc.insets = new Insets(0, 0, 0, 0);
plotBehavior.add(timeAxisPanel, gbc);
gbc.gridy++;
gbc.insets = new Insets(6, 0, 0, 0);
plotBehavior.add(behaviorNonTimeTitlePanel, gbc);
gbc.gridy++;
gbc.insets = new Insets(0, 0, 0, 0);
plotBehavior.add(nonTimeAxisPanel, gbc);
// Instrument
plotBehavior.setName("plotBehavior");
modePanel.setName("modePanel");
bMode.setName("bMode");
minPanel.setName("minPanel");
bMin.setName("bMin");
maxPanel.setName("maxPanel");
timeAxisPanel.setName("timeAxisPanel");
nonTimeAxisPanel.setName("nonTimeAxisPanel");
behaviorTimeAxisLetter.setName("behaviorTimeAxisLetter");
behaviorNonTimeAxisLetter.setName("behaviorNonTimeAxisLetter");
JPanel stillBehavior = new JPanel(new BorderLayout());
stillBehavior.add(plotBehavior, BorderLayout.WEST);
return stillBehavior;
}
// The Non-Time Axis table within the Plot Behavior panel
private GridLinedPanel createGriddedNonTimeAxisPanel() {
JLabel titleMin = new JLabel(BUNDLE.getString("Min.label"));
JLabel titleMax = new JLabel(BUNDLE.getString("Max.label"));
JLabel titlePadding = new JLabel(BUNDLE.getString("Padding.label"));
JLabel titleMinPadding = new JLabel(BUNDLE.getString("Min.label"));
JLabel titleMaxPadding = new JLabel(BUNDLE.getString("Max.label"));
setFontToBold(titleMin);
setFontToBold(titleMax);
setFontToBold(titlePadding);
setFontToBold(titleMinPadding);
setFontToBold(titleMaxPadding);
nonTimeMinAutoAdjustMode = new JRadioButton(BUNDLE.getString("AutoAdjusts.label"));
nonTimeMaxAutoAdjustMode = new JRadioButton(BUNDLE.getString("AutoAdjusts.label"));
nonTimeMinFixedMode = new JRadioButton(BUNDLE.getString("Fixed.label"));
nonTimeMaxFixedMode = new JRadioButton(BUNDLE.getString("Fixed.label"));
JPanel nonTimeMinAutoAdjustModePanel = new JPanel();
nonTimeMinAutoAdjustModePanel.add(nonTimeMinAutoAdjustMode);
JPanel nonTimeMaxAutoAdjustModePanel = new JPanel();
nonTimeMaxAutoAdjustModePanel.add(nonTimeMaxAutoAdjustMode);
JPanel nonTimeMinFixedModePanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 5, 0));
nonTimeMinFixedModePanel.add(nonTimeMinFixedMode);
JPanel nonTimeMaxFixedModePanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 5, 0));
nonTimeMaxFixedModePanel.add(nonTimeMaxFixedMode);
nonTimeMinAutoAdjustMode.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
nonTimeMinSemiFixedMode.setEnabled(false);
nonTimeMinSemiFixedMode.setSelected(false);
}
});
nonTimeMinFixedMode.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if(nonTimeMinFixedMode.isSelected()) {
nonTimeMinSemiFixedMode.setEnabled(true);
} else {
nonTimeMinSemiFixedMode.setEnabled(false);
nonTimeMinSemiFixedMode.setSelected(false);
}
}
});
nonTimeMaxAutoAdjustMode.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
nonTimeMaxSemiFixedMode.setEnabled(false);
nonTimeMaxSemiFixedMode.setSelected(false);
}
});
nonTimeMaxFixedMode.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if(nonTimeMaxFixedMode.isSelected()) {
nonTimeMaxSemiFixedMode.setEnabled(true);
} else {
nonTimeMaxSemiFixedMode.setEnabled(false);
nonTimeMaxSemiFixedMode.setSelected(false);
}
}
});
nonTimeMinAutoAdjustMode.setSelected(true);
nonTimeMaxAutoAdjustMode.setSelected(true);
ButtonGroup minGroup = new ButtonGroup();
minGroup.add(nonTimeMinAutoAdjustMode);
minGroup.add(nonTimeMinFixedMode);
ButtonGroup maxGroup = new ButtonGroup();
maxGroup.add(nonTimeMaxAutoAdjustMode);
maxGroup.add(nonTimeMaxFixedMode);
nonTimeMinSemiFixedMode = new JCheckBox(BUNDLE.getString("SemiFixed.label"));
nonTimeMaxSemiFixedMode = new JCheckBox(BUNDLE.getString("SemiFixed.label"));
JPanel nonTimeMinSemiFixedModePanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 5, 2));
JPanel nonTimeMaxSemiFixedModePanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 5, 2));
nonTimeMinSemiFixedModePanel.add(nonTimeMinSemiFixedMode);
nonTimeMaxSemiFixedModePanel.add(nonTimeMaxSemiFixedMode);
nonTimeMinSemiFixedMode.setEnabled(false);
nonTimeMaxSemiFixedMode.setEnabled(false);
nonTimeMinPadding = createPaddingTextField(AxisType.NON_TIME, AxisBounds.MIN);
nonTimeMaxPadding = createPaddingTextField(AxisType.NON_TIME, AxisBounds.MAX);
JPanel nonTimeMinPaddingPanel = new JPanel();
nonTimeMinPaddingPanel.add(nonTimeMinPadding);
nonTimeMinPaddingPanel.add(new JLabel(BUNDLE.getString("Percent.label")));
JPanel nonTimeMaxPaddingPanel = new JPanel();
nonTimeMaxPaddingPanel.add(nonTimeMaxPadding);
nonTimeMaxPaddingPanel.add(new JLabel(BUNDLE.getString("Percent.label")));
JPanel nonTimeMins = new JPanel();
nonTimeMins.setLayout(new GridBagLayout());
GridBagConstraints gbc0 = new GridBagConstraints();
gbc0.gridy = 0;
gbc0.anchor = GridBagConstraints.WEST;
nonTimeMins.add(nonTimeMinAutoAdjustModePanel, gbc0);
gbc0.gridy = 1;
nonTimeMins.add(nonTimeMinFixedModePanel, gbc0);
gbc0.gridy = 2;
gbc0.insets = new Insets(0, INDENTATION_SEMI_FIXED_CHECKBOX, 0, 0);
nonTimeMins.add(nonTimeMinSemiFixedModePanel, gbc0);
JPanel nonTimeMaxs = new JPanel();
nonTimeMaxs.setLayout(new GridBagLayout());
GridBagConstraints gbc1 = new GridBagConstraints();
gbc1.gridy = 0;
gbc1.anchor = GridBagConstraints.WEST;
nonTimeMaxs.add(nonTimeMaxAutoAdjustModePanel, gbc1);
gbc1.gridy = 1;
nonTimeMaxs.add(nonTimeMaxFixedModePanel, gbc1);
gbc1.gridy = 2;
gbc1.insets = new Insets(0, INDENTATION_SEMI_FIXED_CHECKBOX, 0, 0);
nonTimeMaxs.add(nonTimeMaxSemiFixedModePanel, gbc1);
GridLinedPanel griddedPanel = new GridLinedPanel();
GridBagConstraints gbc = new GridBagConstraints();
gbc.fill = GridBagConstraints.BOTH;
gbc.weightx = 1;
gbc.weighty = 1;
gbc.ipadx = BEHAVIOR_CELLS_X_PADDING;
griddedPanel.setGBC(gbc);
// Title row A
int row = 0;
gbc.gridwidth = 1;
gbc.gridheight = 2; // First 2 titles are 2 rows high
griddedPanel.addCell(titleMin, 1, row);
griddedPanel.addCell(titleMax, 2, row);
gbc.gridwidth = 2; // "Padding" spans 2 columns, 1 row high
gbc.gridheight = 1;
griddedPanel.addCell(titlePadding, 3, row);
gbc.gridwidth = 1;
// Title row B - only 2 cells occupied
row++;
griddedPanel.addCell(titleMinPadding, 3, row);
griddedPanel.addCell(titleMaxPadding, 4, row);
// Row 1
row++;
griddedPanel.addCell(nonTimeMins, 1, row, GridBagConstraints.WEST);
griddedPanel.addCell(nonTimeMaxs, 2, row, GridBagConstraints.WEST);
griddedPanel.addCell(nonTimeMinPaddingPanel, 3, row);
griddedPanel.addCell(nonTimeMaxPaddingPanel, 4, row);
// Instrument
nonTimeMins.setName("nonTimeMins");
nonTimeMaxs.setName("nonTimeMaxs");
return griddedPanel;
}
/*
* This filter blocks non-numeric characters from being entered in the padding fields
*/
class PaddingFilter extends DocumentFilter {
private StringBuilder insertBuilder;
private StringBuilder replaceBuilder;
@Override
public void insertString(FilterBypass fb, int offset, String string, AttributeSet attr)
throws BadLocationException {
insertBuilder = new StringBuilder(string);
for (int k = insertBuilder.length() - 1; k >= 0; k--) {
int cp = insertBuilder.codePointAt(k);
if (! Character.isDigit(cp)) {
insertBuilder.deleteCharAt(k);
if (Character.isSupplementaryCodePoint(cp)) {
k--;
insertBuilder.deleteCharAt(k);
}
}
}
super.insertString(fb, offset, insertBuilder.toString(), attr);
}
@Override
public void replace(FilterBypass fb, int offset, int length, String string, AttributeSet attr)
throws BadLocationException {
replaceBuilder = new StringBuilder(string);
for (int k = replaceBuilder.length() - 1; k >= 0; k--) {
int cp = replaceBuilder.codePointAt(k);
if (! Character.isDigit(cp)) {
replaceBuilder.deleteCharAt(k);
if (Character.isSupplementaryCodePoint(cp)) {
k--;
replaceBuilder.deleteCharAt(k);
}
}
}
super.replace(fb, offset, length, replaceBuilder.toString(), attr);
}
StringBuilder getInsertBuilder() {
return insertBuilder;
}
StringBuilder getReplaceBuilder() {
return replaceBuilder;
}
}
@SuppressWarnings("serial")
private JTextField createPaddingTextField(AxisType axisType, AxisBounds bound) {
final JFormattedTextField tField = new JFormattedTextField(new InternationalFormatter(
NumberFormat.getIntegerInstance()) {
protected DocumentFilter getDocumentFilter() {
return filter;
}
private DocumentFilter filter = new PaddingFilter();
});
tField.setColumns(PADDING_COLUMNS);
tField.setHorizontalAlignment(JTextField.RIGHT);
if (bound.equals(AxisBounds.MIN)) {
tField.setText(axisType.getMinimumDefaultPaddingAsText());
} else {
tField.setText(axisType.getMaximumDefaultPaddingAsText());
}
tField.addAncestorListener(new AncestorListener() {
@Override
public void ancestorAdded(AncestorEvent event) {
tField.selectAll();
tField.removeAncestorListener(this);
}
@Override
public void ancestorMoved(AncestorEvent event) {
}
@Override
public void ancestorRemoved(AncestorEvent event) {
}
});
return tField;
}
private void setFontToBold(JLabel item) {
item.setFont(item.getFont().deriveFont(Font.BOLD));
}
// The Time Axis table within the Plot Behavior area
private GridLinedPanel createGriddedTimeAxisPanel() {
JLabel titleMode = new JLabel(BUNDLE.getString("Mode.label"));
JLabel titleMin = new JLabel(BUNDLE.getString("Min.label"));
JLabel titleMinPadding = new JLabel(BUNDLE.getString("Min.label"));
JLabel titleMax = new JLabel(BUNDLE.getString("Max.label"));
JLabel titleMaxPadding = new JLabel(BUNDLE.getString("Max.label"));
JLabel titleSpan = new JLabel(BUNDLE.getString("Span.label"));
JLabel titleMax_Min = new JLabel("(" + BUNDLE.getString("MaxMinusMin.label") +")");
JPanel titlePanelSpan = new JPanel();
titlePanelSpan.setLayout(new BoxLayout(titlePanelSpan, BoxLayout.Y_AXIS));
titlePanelSpan.add(titleSpan);
titlePanelSpan.add(titleMax_Min);
titleSpan.setAlignmentX(Component.CENTER_ALIGNMENT);
titleMax_Min.setAlignmentX(Component.CENTER_ALIGNMENT);
JLabel titlePaddingOnRedraw = new JLabel(BUNDLE.getString("PaddingOnRedraw.label"));
setFontToBold(titleMode);
setFontToBold(titleMin);
setFontToBold(titleMax);
setFontToBold(titleMinPadding);
setFontToBold(titleMaxPadding);
setFontToBold(titlePaddingOnRedraw);
setFontToBold(titleSpan);
setFontToBold(titleMax_Min);
timeJumpMode = new JRadioButton(BUNDLE.getString("Jump.label"));
timeScrunchMode = new JRadioButton(BUNDLE.getString("Scrunch.label"));
JPanel timeJumpModePanel = new JPanel();
timeJumpModePanel.add(timeJumpMode);
JPanel timeScrunchModePanel = new JPanel();
timeScrunchModePanel.add(timeScrunchMode);
ButtonGroup modeGroup = new ButtonGroup();
modeGroup.add(timeJumpMode);
modeGroup.add(timeScrunchMode);
timeJumpMode.setSelected(true);
timeJumpPadding = createPaddingTextField(AxisType.TIME_IN_JUMP_MODE, AxisBounds.MAX);
timeScrunchPadding = createPaddingTextField(AxisType.TIME_IN_SCRUNCH_MODE, AxisBounds.MAX);
JPanel timeJumpPaddingPanel = new JPanel();
timeJumpPaddingPanel.add(timeJumpPadding);
timeJumpPaddingPanel.add(new JLabel(BUNDLE.getString("Percent.label")));
JPanel timeScrunchPaddingPanel = new JPanel();
timeScrunchPaddingPanel.add(timeScrunchPadding);
timeScrunchPaddingPanel.add(new JLabel(BUNDLE.getString("Percent.label")));
GridLinedPanel griddedPanel = new GridLinedPanel();
GridBagConstraints gbc = new GridBagConstraints();
gbc.gridwidth = 1;
gbc.fill = GridBagConstraints.BOTH;
gbc.weightx = 1;
gbc.weighty = 1;
gbc.ipadx = BEHAVIOR_CELLS_X_PADDING;
gbc.gridheight = 2;
griddedPanel.setGBC(gbc);
// Title row A
int row = 0;
griddedPanel.addCell(titleMode, 0, row);
griddedPanel.addCell(titleMin, 1, row);
griddedPanel.addCell(titleMax, 2, row);
gbc.gridheight = 2;
griddedPanel.addCell(titlePanelSpan, 3, row);
gbc.gridheight = 1;
gbc.gridwidth = 2;
griddedPanel.addCell(titlePaddingOnRedraw, 4, row);
gbc.gridwidth = 1;
// Title row B - only two entries
row++;
griddedPanel.addCell(titleMinPadding, 4, row);
griddedPanel.addCell(titleMaxPadding, 5, row);
// Row 1
row++;
griddedPanel.addCell(timeJumpModePanel, 0, row, GridBagConstraints.WEST);
griddedPanel.addCell(new JLabel(BUNDLE.getString("AutoAdjusts.label")), 1, row);
griddedPanel.addCell(new JLabel(BUNDLE.getString("AutoAdjusts.label")), 2, row);
griddedPanel.addCell(new JLabel(BUNDLE.getString("Fixed.label")), 3, row);
griddedPanel.addCell(new JLabel(BUNDLE.getString("Dash.label")), 4, row);
griddedPanel.addCell(timeJumpPaddingPanel, 5, row);
// Row 2
row++;
griddedPanel.addCell(timeScrunchModePanel, 0, row, GridBagConstraints.WEST);
griddedPanel.addCell(new JLabel(BUNDLE.getString("Fixed.label")), 1, row);
griddedPanel.addCell(new JLabel(BUNDLE.getString("AutoAdjusts.label")), 2, row);
griddedPanel.addCell(new JLabel(BUNDLE.getString("AutoAdjusts.label")), 3, row);
griddedPanel.addCell(new JLabel(BUNDLE.getString("Dash.label")), 4, row);
griddedPanel.addCell(timeScrunchPaddingPanel, 5, row);
return griddedPanel;
}
static class GridLinedPanel extends JPanel {
private static final long serialVersionUID = -1227455333903006294L;
private GridBagConstraints wrapGbc;
public GridLinedPanel() {
setLayout(new GridBagLayout());
setBorder(BorderFactory.createLineBorder(Color.gray));
}
void setGBC(GridBagConstraints inputGbc) {
wrapGbc = inputGbc;
}
// Wrap each added ui control in a JPanel with a border
void addCell(JLabel uiControl, int xPosition, int yPosition) {
uiControl.setHorizontalAlignment(JLabel.CENTER);
wrapControlInPanel(uiControl, xPosition, yPosition);
}
// Wrap each added ui control in a JPanel with a border
void addCell(JPanel uiControl, int xPosition, int yPosition) {
wrapControlInPanel(uiControl, xPosition, yPosition);
}
private void wrapControlInPanel(JComponent uiControl, int xPosition,
int yPosition) {
JPanel wrapperPanel = new JPanel();
wrapperPanel.setLayout(new GridBagLayout());
GridBagConstraints gbc = new GridBagConstraints();
wrapperPanel.add(uiControl, gbc);
wrapGbc.gridx = xPosition;
wrapGbc.gridy = yPosition;
wrapperPanel.setBorder(new LineBorder(Color.lightGray));
add(wrapperPanel, wrapGbc);
}
private void addCell(JComponent uiControl, int xPosition,
int yPosition, int alignment) {
JPanel wrapperPanel = new JPanel(new GridBagLayout());
wrapperPanel.setBorder(new LineBorder(Color.lightGray));
GridBagConstraints gbc = new GridBagConstraints();
if (alignment == GridBagConstraints.WEST) {
gbc.weightx = 1;
gbc.anchor = GridBagConstraints.WEST;
}
wrapperPanel.add(uiControl, gbc);
wrapGbc.gridx = xPosition;
wrapGbc.gridy = yPosition;
add(wrapperPanel, wrapGbc);
}
}
private JPanel getLineSetupPanel() {
JPanel panel = new JPanel();
drawLabel = new JLabel(BUNDLE.getString("Draw.label"));
linesOnly = new JRadioButton(BUNDLE.getString("LinesOnly.label"));
markersAndLines = new JRadioButton(BUNDLE.getString("MarkersAndLines.label"));
markersOnly = new JRadioButton(BUNDLE.getString("MarkersOnly.label"));
connectionLineTypeLabel = new JLabel(BUNDLE.getString("ConnectionLineType.label"));
direct = new JRadioButton(BUNDLE.getString("Direct.label"));
step = new JRadioButton(BUNDLE.getString("Step.label"));
direct.setToolTipText(BUNDLE.getString("Direct.tooltip"));
step.setToolTipText(BUNDLE.getString("Step.tooltip"));
panel.setLayout(new GridBagLayout());
GridBagConstraints gbc = new GridBagConstraints();
gbc.ipady = 4;
gbc.ipadx = BEHAVIOR_CELLS_X_PADDING;
gbc.anchor = GridBagConstraints.WEST;
gbc.gridx = 0;
gbc.gridy = 0;
gbc.gridwidth = 1;
gbc.gridheight = 1;
gbc.fill = GridBagConstraints.NONE;
panel.add(drawLabel, gbc);
gbc.gridy++;
panel.add(linesOnly, gbc);
gbc.gridy++;
panel.add(markersAndLines, gbc);
gbc.gridy++;
panel.add(markersOnly, gbc);
gbc.gridx = 1;
gbc.gridy = 0;
gbc.gridheight = 4;
gbc.fill = GridBagConstraints.VERTICAL;
panel.add(new JSeparator(JSeparator.VERTICAL), gbc);
gbc.gridx = 2;
gbc.gridy = 0;
gbc.gridwidth = 1;
gbc.gridheight = 1;
gbc.fill = GridBagConstraints.NONE;
panel.add(connectionLineTypeLabel, gbc);
gbc.gridy++;
panel.add(direct, gbc);
gbc.gridy++;
panel.add(step, gbc);
JPanel parent = new JPanel();
parent.setLayout(new BorderLayout());
parent.add(panel, BorderLayout.WEST);
parent.setBorder(SETUP_AND_BEHAVIOR_MARGINS);
ButtonGroup drawGroup = new ButtonGroup();
drawGroup.add(linesOnly);
drawGroup.add(markersAndLines);
drawGroup.add(markersOnly);
ButtonGroup connectionGroup = new ButtonGroup();
connectionGroup.add(direct);
connectionGroup.add(step);
ActionListener disabler = new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
boolean linesShowing = !markersOnly.isSelected();
connectionLineTypeLabel.setEnabled(linesShowing);
direct.setEnabled(linesShowing);
step.setEnabled(linesShowing);
}
};
linesOnly.addActionListener(disabler);
markersAndLines.addActionListener(disabler);
markersOnly.addActionListener(disabler);
return parent;
}
/**
* Set the state of the widgets in the setting panel according to those specified in the parameters.
* @param timeAxisSetting
* @param xAxisMaximumLocation
* @param yAxisMaximumLocation
* @param timeAxisSubsequentSetting
* @param nonTimeAxisSubsequentMinSetting
* @param nonTimeAxisSubsequentMaxSetting
* @param nonTimeMax
* @param nonTimeMin
* @param minTime
* @param maxTime
* @param timePadding
* @param plotLineDraw indicates how to draw the plot (whether to include lines, markers, etc)
* @param plotLineConnectionType the method of connecting lines on the plot
*/
public void setControlPanelState(AxisOrientationSetting timeAxisSetting,
XAxisMaximumLocationSetting xAxisMaximumLocation,
YAxisMaximumLocationSetting yAxisMaximumLocation,
TimeAxisSubsequentBoundsSetting timeAxisSubsequentSetting,
NonTimeAxisSubsequentBoundsSetting nonTimeAxisSubsequentMinSetting,
NonTimeAxisSubsequentBoundsSetting nonTimeAxisSubsequentMaxSetting,
double nonTimeMax, double nonTimeMin, long minTime,
long maxTime,
double timePadding,
double nonTimePaddingMax,
double nonTimePaddingMin,
boolean groupStackPlotsByOrdinalPosition, boolean timeAxisPinned,
PlotLineDrawingFlags plotLineDraw,
PlotLineConnectionType plotLineConnectionType) {
if (plotViewManifestion.getPlot() == null) {
throw new IllegalArgumentException("Plot Setting control Panel cannot be setup if the PltViewManifestation's plot is null");
}
pinTimeAxis.setSelected(timeAxisPinned);
assert nonTimeMin < nonTimeMax : "Non Time min >= Non Time Max";
assert minTime < maxTime : "Time min >= Time Max " + minTime + " " + maxTime;
// Setup time axis setting.
if (timeAxisSetting == AxisOrientationSetting.X_AXIS_AS_TIME) {
xAxisAsTimeRadioButton.setSelected(true);
yAxisAsTimeRadioButton.setSelected(false);
xAxisAsTimeRadioButtonActionPerformed();
} else if (timeAxisSetting == AxisOrientationSetting.Y_AXIS_AS_TIME) {
xAxisAsTimeRadioButton.setSelected(false);
yAxisAsTimeRadioButton.setSelected(true);
yAxisAsTimeRadioButtonActionPerformed();
} else {
assert false :"Time must be specified as being on either the X or Y axis.";
}
// X Max setting
if (xAxisMaximumLocation == XAxisMaximumLocationSetting.MAXIMUM_AT_RIGHT) {
xMaxAtRight.setSelected(true);
xMaxAtLeft.setSelected(false);
xMaxAtRightActionPerformed();
} else if (xAxisMaximumLocation == XAxisMaximumLocationSetting.MAXIMUM_AT_LEFT) {
xMaxAtRight.setSelected(false);
xMaxAtLeft.setSelected(true);
xMaxAtLeftActionPerformed();
} else {
assert false: "X max location must be set.";
}
// Y Max setting
if (yAxisMaximumLocation == YAxisMaximumLocationSetting.MAXIMUM_AT_TOP) {
yMaxAtTop.setSelected(true);
yMaxAtBottom.setSelected(false);
yMaxAtTopActionPerformed();
} else if (yAxisMaximumLocation == YAxisMaximumLocationSetting.MAXIMUM_AT_BOTTOM) {
yMaxAtTop.setSelected(false);
yMaxAtBottom.setSelected(true);
yMaxAtBottomActionPerformed();
} else {
assert false: "Y max location must be set.";
}
if (timeAxisSubsequentSetting == TimeAxisSubsequentBoundsSetting.JUMP) {
timeJumpMode.setSelected(true);
timeScrunchMode.setSelected(false);
timeJumpPadding.setText(timePaddingFormat.format(timePadding * 100));
timeAxisMaxAuto.setSelected(false);
timeAxisMaxManual.setSelected(false);
timeAxisMaxCurrent.setSelected(true);
timeAxisMinAuto.setSelected(false);
timeAxisMinManual.setSelected(false);
timeAxisMinCurrent.setSelected(true);
workCalendar.setTime(plotViewManifestion.getPlot().getMaxTime().getTime());
timeAxisMaxManualValue.setTime(workCalendar);
workCalendar.setTime(plotViewManifestion.getPlot().getMinTime().getTime());
timeAxisMinManualValue.setTime(workCalendar);
} else if (timeAxisSubsequentSetting == TimeAxisSubsequentBoundsSetting.SCRUNCH) {
timeJumpMode.setSelected(false);
timeScrunchMode.setSelected(true);
timeScrunchPadding.setText(timePaddingFormat.format(timePadding * 100));
timeAxisMaxAuto.setSelected(false);
timeAxisMaxManual.setSelected(false);
timeAxisMaxCurrent.setSelected(true);
timeAxisMinAuto.setSelected(false);
timeAxisMinManual.setSelected(false);
timeAxisMinCurrent.setSelected(true);
GregorianCalendar minCalendar = new GregorianCalendar();
minCalendar.setTimeZone(dateFormat.getTimeZone());
minCalendar.setTimeInMillis(minTime);
timeAxisMinManualValue.setTime(minCalendar);
} else {
assert false : "No time subsequent mode selected";
}
// Set the Current Min and Max values
timeAxisMinCurrentValue.setTime(plotViewManifestion.getPlot().getMinTime());
timeAxisMaxCurrentValue.setTime(plotViewManifestion.getPlot().getMaxTime());
// Non Time Subsequent Settings
// Min
if (NonTimeAxisSubsequentBoundsSetting.AUTO == nonTimeAxisSubsequentMinSetting) {
nonTimeMinAutoAdjustMode.setSelected(true);
nonTimeMinFixedMode.setSelected(false);
nonTimeMinSemiFixedMode.setSelected(false);
nonTimeMinSemiFixedMode.setEnabled(false);
} else if (NonTimeAxisSubsequentBoundsSetting.FIXED == nonTimeAxisSubsequentMinSetting) {
nonTimeMinAutoAdjustMode.setSelected(false);
nonTimeMinFixedMode.setSelected(true);
nonTimeMinSemiFixedMode.setSelected(false);
nonTimeMinSemiFixedMode.setEnabled(true);
} else if (NonTimeAxisSubsequentBoundsSetting.SEMI_FIXED == nonTimeAxisSubsequentMinSetting) {
nonTimeMinAutoAdjustMode.setSelected(false);
nonTimeMinFixedMode.setSelected(true);
nonTimeMinSemiFixedMode.setSelected(true);
nonTimeMinSemiFixedMode.setEnabled(true);
} else {
assert false : "No non time min subsequent setting specified";
}
// Max
if (NonTimeAxisSubsequentBoundsSetting.AUTO == nonTimeAxisSubsequentMaxSetting) {
nonTimeMaxAutoAdjustMode.setSelected(true);
nonTimeMaxFixedMode.setSelected(false);
nonTimeMaxSemiFixedMode.setSelected(false);
nonTimeMaxSemiFixedMode.setEnabled(false);
} else if (NonTimeAxisSubsequentBoundsSetting.FIXED == nonTimeAxisSubsequentMaxSetting) {
nonTimeMaxAutoAdjustMode.setSelected(false);
nonTimeMaxFixedMode.setSelected(true);
nonTimeMaxSemiFixedMode.setSelected(false);
nonTimeMaxSemiFixedMode.setEnabled(true);
} else if (NonTimeAxisSubsequentBoundsSetting.SEMI_FIXED == nonTimeAxisSubsequentMaxSetting) {
nonTimeMaxAutoAdjustMode.setSelected(false);
nonTimeMaxFixedMode.setSelected(true);
nonTimeMaxSemiFixedMode.setSelected(true);
nonTimeMaxSemiFixedMode.setEnabled(true);
} else {
assert false : "No non time max subsequent setting specified";
}
// Non time Axis Settings.
// Non-Time Min. Control Panel
if (NonTimeAxisSubsequentBoundsSetting.AUTO == nonTimeAxisSubsequentMinSetting) {
nonTimeAxisMinCurrent.setSelected(true);
nonTimeAxisMinManual.setSelected(false);
nonTimeAxisMinAutoAdjust.setSelected(false);
nonTimeMinPadding.setText(nonTimePaddingFormat.format(nonTimePaddingMin * 100));
} else if (NonTimeAxisSubsequentBoundsSetting.SEMI_FIXED == nonTimeAxisSubsequentMinSetting
|| NonTimeAxisSubsequentBoundsSetting.FIXED == nonTimeAxisSubsequentMinSetting) {
nonTimeAxisMinCurrent.setSelected(false);
if (!nonTimeAxisMinManual.isSelected()) {
nonTimeAxisMinManual.setSelected(true);
}
nonTimeAxisMinManualValue.setText(nonTimePaddingFormat.format(nonTimeMin));
nonTimeAxisMinAutoAdjust.setSelected(false);
}
// Non-Time Max. Control Panel
if (NonTimeAxisSubsequentBoundsSetting.AUTO == nonTimeAxisSubsequentMaxSetting) {
nonTimeAxisMaxCurrent.setSelected(true);
nonTimeAxisMaxManual.setSelected(false);
nonTimeAxisMaxAutoAdjust.setSelected(false);
nonTimeMaxPadding.setText(nonTimePaddingFormat.format(nonTimePaddingMax * 100));
} else if (NonTimeAxisSubsequentBoundsSetting.SEMI_FIXED == nonTimeAxisSubsequentMaxSetting
|| NonTimeAxisSubsequentBoundsSetting.FIXED == nonTimeAxisSubsequentMaxSetting) {
nonTimeAxisMaxCurrent.setSelected(false);
if (!nonTimeAxisMaxManual.isSelected()) {
nonTimeAxisMaxManual.setSelected(true);
}
nonTimeAxisMaxManualValue.setText(nonTimePaddingFormat.format(nonTimeMax));
nonTimeAxisMaxAutoAdjust.setSelected(false);
}
// Draw
if (plotLineDraw.drawLine() && plotLineDraw.drawMarkers()) {
markersAndLines.setSelected(true);
} else if (plotLineDraw.drawLine()) {
linesOnly.setSelected(true);
} else if (plotLineDraw.drawMarkers()) {
markersOnly.setSelected(true);
} else {
logger.warn("Plot line drawing configuration is unset.");
}
// Connection line type
if (plotLineConnectionType == PlotLineConnectionType.DIRECT) {
direct.setSelected(true);
} else if (plotLineConnectionType == PlotLineConnectionType.STEP_X_THEN_Y) {
step.setSelected(true);
}
updateTimeAxisControls();
groupByCollection.setSelected(!groupStackPlotsByOrdinalPosition);
}
// Get the plot setting from the GUI widgets, inform the plot controller and request a new plot.
void setupPlot() {
// Axis on which time will be displayed
if ( xAxisAsTimeRadioButton.isSelected() ) {
assert !yAxisAsTimeRadioButton.isSelected() : "Both axis location boxes are selected!";
controller.setTimeAxis(AxisOrientationSetting.X_AXIS_AS_TIME);
} else if (yAxisAsTimeRadioButton.isSelected()) {
controller.setTimeAxis(AxisOrientationSetting.Y_AXIS_AS_TIME);
} else {
assert false: "Time must be specified as being on either the X or Y axis.";
controller.setTimeAxis(AxisOrientationSetting.X_AXIS_AS_TIME);
}
// X Max Location setting
if (xMaxAtRight.isSelected()) {
assert !xMaxAtLeft.isSelected(): "Both x max location settings are selected!";
controller.setXAxisMaximumLocation(XAxisMaximumLocationSetting.MAXIMUM_AT_RIGHT);
} else if (xMaxAtLeft.isSelected()) {
controller.setXAxisMaximumLocation(XAxisMaximumLocationSetting.MAXIMUM_AT_LEFT);
} else {
assert false: "X max location must be set.";
controller.setXAxisMaximumLocation(XAxisMaximumLocationSetting.MAXIMUM_AT_RIGHT);
}
// Y Max Location setting
if (yMaxAtTop.isSelected()) {
assert !yMaxAtBottom.isSelected(): "Both y max location settings are selected!";
controller.setYAxisMaximumLocation(YAxisMaximumLocationSetting.MAXIMUM_AT_TOP);
} else if (yMaxAtBottom.isSelected()) {
controller.setYAxisMaximumLocation(YAxisMaximumLocationSetting.MAXIMUM_AT_BOTTOM);
} else {
assert false: "Y max location must be set.";
controller.setYAxisMaximumLocation(YAxisMaximumLocationSetting.MAXIMUM_AT_TOP);
}
controller.setTimeAxisPinned(pinTimeAxis.isSelected());
// Time Subsequent settings
if (timeJumpMode.isSelected()) {
assert !timeScrunchMode.isSelected() : "Both jump and scruch are set!";
controller.setTimeAxisSubsequentBounds(TimeAxisSubsequentBoundsSetting.JUMP);
controller.setTimePadding(Double.valueOf(timeJumpPadding.getText()).doubleValue() / 100.);
} else if (timeScrunchMode.isSelected()) {
assert !timeJumpMode.isSelected() : "Both scrunch and jump are set!";
controller.setTimeAxisSubsequentBounds(TimeAxisSubsequentBoundsSetting.SCRUNCH);
controller.setTimePadding(Double.valueOf(timeScrunchPadding.getText()).doubleValue() / 100.);
} else {
assert false : "No time subsequent mode selected";
controller.setTimeAxisSubsequentBounds(TimeAxisSubsequentBoundsSetting.JUMP);
}
// Non Time Subsequent Settings
// Min
if (nonTimeMinAutoAdjustMode.isSelected()) {
assert !nonTimeMinFixedMode.isSelected() : "Both non time min subsequent modes are selected!";
controller.setNonTimeAxisSubsequentMinBounds(NonTimeAxisSubsequentBoundsSetting.AUTO);
} else if (nonTimeMinFixedMode.isSelected() && !nonTimeMinSemiFixedMode.isSelected()) {
assert !nonTimeMinAutoAdjustMode.isSelected() : "Both non time min subsequent modes are selected!";
controller.setNonTimeAxisSubsequentMinBounds(NonTimeAxisSubsequentBoundsSetting.FIXED);
} else if (nonTimeMinFixedMode.isSelected() && nonTimeMinSemiFixedMode.isSelected()) {
assert !nonTimeMinAutoAdjustMode.isSelected() : "Both non time min subsequent modes are selected!";
controller.setNonTimeAxisSubsequentMinBounds(NonTimeAxisSubsequentBoundsSetting.SEMI_FIXED);
} else {
assert false : "No non time min subsequent setting specified";
controller.setNonTimeAxisSubsequentMinBounds(NonTimeAxisSubsequentBoundsSetting.AUTO);
}
controller.setNonTimeMinPadding(Double.parseDouble(nonTimeMinPadding.getText()) / 100.);
// Max
if (nonTimeMaxAutoAdjustMode.isSelected()) {
assert !nonTimeMaxFixedMode.isSelected() : "Both non time max subsequent modes are selected!";
controller.setNonTimeAxisSubsequentMaxBounds(NonTimeAxisSubsequentBoundsSetting.AUTO);
} else if (nonTimeMaxFixedMode.isSelected() && !nonTimeMaxSemiFixedMode.isSelected()) {
assert !nonTimeMaxAutoAdjustMode.isSelected() : "Both non time max subsequent modes are selected!";
controller.setNonTimeAxisSubsequentMaxBounds(NonTimeAxisSubsequentBoundsSetting.FIXED);
} else if (nonTimeMaxFixedMode.isSelected() && nonTimeMaxSemiFixedMode.isSelected()) {
assert !nonTimeMaxAutoAdjustMode.isSelected() : "Both non time max subsequent modes are selected!";
controller.setNonTimeAxisSubsequentMaxBounds(NonTimeAxisSubsequentBoundsSetting.SEMI_FIXED);
} else {
assert false : "No non time ax subsequent setting specified";
controller.setNonTimeAxisSubsequentMaxBounds(NonTimeAxisSubsequentBoundsSetting.AUTO);
}
controller.setNonTimeMaxPadding(Double.valueOf(nonTimeMaxPadding.getText()).doubleValue() / 100.);
// Time
GregorianCalendar timeMin = recycledCalendarA;
GregorianCalendar timeMax = recycledCalendarB;
if (timeAxisMinAuto.isSelected()) {
GregorianCalendar gc = new GregorianCalendar();
gc.setTimeInMillis(plotViewManifestion.getCurrentMCTTime());
timeMin = gc;
} else if (timeAxisMinManual.isSelected()) {
timeMin.setTimeInMillis(timeAxisMinManualValue.getValueInMillis());
} else if (timeAxisMinCurrent.isSelected()) {
timeMin.setTimeInMillis(timeAxisMinCurrentValue.getTimeInMillis());
} else throw new IllegalArgumentException("No time setting button is selected.");
if (timeAxisMaxAuto.isSelected()) {
timeMax.setTime(timeMin.getTime());
timeMax.add(Calendar.SECOND, timeSpanValue.getSecond());
timeMax.add(Calendar.MINUTE, timeSpanValue.getMinute());
timeMax.add(Calendar.HOUR_OF_DAY, timeSpanValue.getHourOfDay());
timeMax.add(Calendar.DAY_OF_YEAR, timeSpanValue.getDayOfYear());
} else if (timeAxisMaxManual.isSelected()) {
timeMax.setTimeInMillis(timeAxisMaxManualValue.getValueInMillis());
} else if (timeAxisMaxCurrent.isSelected()) {
timeMax.setTimeInMillis(timeAxisMaxCurrentValue.getTimeInMillis());
} else throw new IllegalArgumentException("No time setting button is selected.");
// Check that values are valid.
assert timeMin.getTimeInMillis() < timeMax.getTimeInMillis() : "Time min is > timeMax. Min = "
+ CalendarDump.dumpDateAndTime(timeMin) + ", Max = " + CalendarDump.dumpDateAndTime(timeMax);
if (timeMin.getTimeInMillis() < timeMax.getTimeInMillis()) {
controller.setTimeMinMaxValues(timeMin, timeMax);
} else {
logger.warn("User error - The minimum time was not less than the maximum time");
}
double nonTimeMin = 0.0;
double nonTimeMax = 1.0;
// Non time
if (nonTimeAxisMinCurrent.isSelected()) {
nonTimeMin = plotViewManifestion.getMinFeedValue();
} else if (nonTimeAxisMinManual.isSelected()) {
nonTimeMin = Double.valueOf(nonTimeAxisMinManualValue.getText()).doubleValue();
} else if (nonTimeAxisMinAutoAdjust.isSelected()) {
nonTimeMin = nonTimeAxisMinAutoAdjustValue.getValue();
} else {
logger.error("Non Time min axis setting not yet supported.");
}
if (nonTimeAxisMaxCurrent.isSelected()) {
nonTimeMax = plotViewManifestion.getMaxFeedValue();
} else if (nonTimeAxisMaxManual.isSelected()) {
nonTimeMax = Double.valueOf(nonTimeAxisMaxManualValue.getText()).doubleValue();
} else if (nonTimeAxisMaxAutoAdjust.isSelected()) {
nonTimeMax = nonTimeAxisMaxAutoAdjustValue.getValue();
} else {
logger.error("Non Time Max axis setting not yet supported.");
}
if (nonTimeMin >= nonTimeMax) {
nonTimeMin = 0.0;
nonTimeMax = 1.0;
}
// Draw
controller.setPlotLineDraw(new PlotLineDrawingFlags(
linesOnly.isSelected() || markersAndLines.isSelected(),
markersOnly.isSelected() || markersAndLines.isSelected()
));
// Connection line type
if (direct.isSelected()) {
controller.setPlotLineConnectionType(PlotLineConnectionType.DIRECT);
} else if (step.isSelected()) {
controller.setPlotLineConnectionType(PlotLineConnectionType.STEP_X_THEN_Y);
}
controller.setUseOrdinalPositionToGroupSubplots(!groupByCollection.isSelected());
controller.setNonTimeMinMaxValues(nonTimeMin, nonTimeMax);
// Settings complete. Create plot.
controller.createPlot();
}
/**
* Return the controller associated with this settings panel. Usage intent is for testing only,
* hence this is package private.
* @return
*/
PlotSettingController getController() {
return controller;
}
public void updateControlsToMatchPlot() {
resetButton.setEnabled(true);
resetButton.doClick(0);
}
} | true | fastPlotViews_src_main_java_gov_nasa_arc_mct_fastplot_view_PlotSettingsControlPanel.java |
749 | addAncestorListener(new AncestorListener () {
@Override
public void ancestorAdded(AncestorEvent event) {
}
@Override
public void ancestorMoved(AncestorEvent event) {
}
@Override
public void ancestorRemoved(AncestorEvent event) {
// this could be changed to use resetButton.doClick();
ActionListener[] resetListeners = resetButton.getActionListeners();
if (resetListeners.length == 1) {
resetListeners[0].actionPerformed(null);
} else {
logger.error("Reset button has unexpected listeners.");
}
}
}); | false | fastPlotViews_src_main_java_gov_nasa_arc_mct_fastplot_view_PlotSettingsControlPanel.java |
750 | nonTimeSpanValue.addFocusListener(new FocusAdapter() {
@Override
public void focusLost(FocusEvent e) {
if (e.isTemporary())
return;
updateNonTimeAxisControls();
}
}); | false | fastPlotViews_src_main_java_gov_nasa_arc_mct_fastplot_view_PlotSettingsControlPanel.java |
751 | timeAxisMinManualValue.addFocusListener(new TimeFieldFocusListener(timeAxisMinManual) {
@Override
public void focusGained(FocusEvent e) {
timeMinManualHasBeenSelected = true;
super.focusGained(e);
}
}); | false | fastPlotViews_src_main_java_gov_nasa_arc_mct_fastplot_view_PlotSettingsControlPanel.java |
752 | timeAxisMaxManualValue.addFocusListener(new TimeFieldFocusListener(timeAxisMaxManual) {
@Override
public void focusGained(FocusEvent e) {
timeMaxManualHasBeenSelected = true;
super.focusGained(e);
}
}); | false | fastPlotViews_src_main_java_gov_nasa_arc_mct_fastplot_view_PlotSettingsControlPanel.java |
753 | timeJumpPadding.addFocusListener(new TimePaddingFocusListener() {
@Override
public void focusGained(FocusEvent e) {
timeJumpMode.setSelected(true);
}
}); | false | fastPlotViews_src_main_java_gov_nasa_arc_mct_fastplot_view_PlotSettingsControlPanel.java |
754 | timeScrunchPadding.addFocusListener(new TimePaddingFocusListener() {
@Override
public void focusGained(FocusEvent e) {
timeScrunchMode.setSelected(true);
}
}); | false | fastPlotViews_src_main_java_gov_nasa_arc_mct_fastplot_view_PlotSettingsControlPanel.java |
755 | FocusListener nontimePaddingListener = new FocusAdapter() {
@Override
public void focusLost(FocusEvent e) {
if (e.isTemporary())
return;
updateNonTimeAxisControls();
}
}; | false | fastPlotViews_src_main_java_gov_nasa_arc_mct_fastplot_view_PlotSettingsControlPanel.java |
756 | okButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
setupPlot();
PlotAbstraction plot = plotViewManifestion.getPlot();
if (plot!=null){
setControlPanelState(plot.getAxisOrientationSetting(),
plot.getXAxisMaximumLocation(),
plot.getYAxisMaximumLocation(),
plot.getTimeAxisSubsequentSetting(),
plot.getNonTimeAxisSubsequentMinSetting(),
plot.getNonTimeAxisSubsequentMaxSetting(),
plot.getNonTimeMax(),
plot.getNonTimeMin(),
plot.getTimeMin(),
plot.getTimeMax(),
plot.getTimePadding(),
plot.getNonTimeMaxPadding(),
plot.getNonTimeMinPadding(),
plot.useOrdinalPositionForSubplots(),
plot.getTimeAxisUserPin().isPinned(),
plot.getPlotLineDraw(),
plot.getPlotLineConnectionType());
}
okButton.setEnabled(false);
saveUIControlsSettings();
plotViewManifestion.getManifestedComponent().save();
}
}); | false | fastPlotViews_src_main_java_gov_nasa_arc_mct_fastplot_view_PlotSettingsControlPanel.java |
757 | resetButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
PlotAbstraction plot = plotViewManifestion.getPlot();
if (plot!=null){
setControlPanelState(plot.getAxisOrientationSetting(),
plot.getXAxisMaximumLocation(),
plot.getYAxisMaximumLocation(),
plot.getTimeAxisSubsequentSetting(),
plot.getNonTimeAxisSubsequentMinSetting(),
plot.getNonTimeAxisSubsequentMaxSetting(),
plot.getNonTimeMax(),
plot.getNonTimeMin(),
plot.getTimeMin(),
plot.getTimeMax(),
plot.getTimePadding(),
plot.getNonTimeMaxPadding(),
plot.getNonTimeMinPadding(),
plot.useOrdinalPositionForSubplots(),
plot.getTimeAxisUserPin().isPinned(),
plot.getPlotLineDraw(),
plot.getPlotLineConnectionType());
}
okButton.setEnabled(false);
resetButton.setEnabled(false);
saveUIControlsSettings();
}
}); | false | fastPlotViews_src_main_java_gov_nasa_arc_mct_fastplot_view_PlotSettingsControlPanel.java |
758 | groupByCollection.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
updateMainButtons();
}
}); | false | fastPlotViews_src_main_java_gov_nasa_arc_mct_fastplot_view_PlotSettingsControlPanel.java |
759 | xAxisAsTimeRadioButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
xAxisAsTimeRadioButtonActionPerformed();
}
}); | false | fastPlotViews_src_main_java_gov_nasa_arc_mct_fastplot_view_PlotSettingsControlPanel.java |
760 | timeDropdown.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
updateMainButtons();
}
}); | false | fastPlotViews_src_main_java_gov_nasa_arc_mct_fastplot_view_PlotSettingsControlPanel.java |
761 | yAxisAsTimeRadioButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
yAxisAsTimeRadioButtonActionPerformed();
}
}); | false | fastPlotViews_src_main_java_gov_nasa_arc_mct_fastplot_view_PlotSettingsControlPanel.java |
762 | xMaxAtRight.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
xMaxAtRightActionPerformed();
}
}); | false | fastPlotViews_src_main_java_gov_nasa_arc_mct_fastplot_view_PlotSettingsControlPanel.java |
763 | xMaxAtLeft.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
xMaxAtLeftActionPerformed();
}
}); | false | fastPlotViews_src_main_java_gov_nasa_arc_mct_fastplot_view_PlotSettingsControlPanel.java |
764 | yMaxAtTop.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
yMaxAtTopActionPerformed();
}
}); | false | fastPlotViews_src_main_java_gov_nasa_arc_mct_fastplot_view_PlotSettingsControlPanel.java |
765 | yMaxAtBottom.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
yMaxAtBottomActionPerformed();
}
}); | false | fastPlotViews_src_main_java_gov_nasa_arc_mct_fastplot_view_PlotSettingsControlPanel.java |
766 | nonTimeMinAutoAdjustMode.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
nonTimeMinSemiFixedMode.setEnabled(false);
nonTimeMinSemiFixedMode.setSelected(false);
}
}); | false | fastPlotViews_src_main_java_gov_nasa_arc_mct_fastplot_view_PlotSettingsControlPanel.java |
767 | nonTimeMinFixedMode.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if(nonTimeMinFixedMode.isSelected()) {
nonTimeMinSemiFixedMode.setEnabled(true);
} else {
nonTimeMinSemiFixedMode.setEnabled(false);
nonTimeMinSemiFixedMode.setSelected(false);
}
}
}); | false | fastPlotViews_src_main_java_gov_nasa_arc_mct_fastplot_view_PlotSettingsControlPanel.java |
768 | nonTimeMaxAutoAdjustMode.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
nonTimeMaxSemiFixedMode.setEnabled(false);
nonTimeMaxSemiFixedMode.setSelected(false);
}
}); | false | fastPlotViews_src_main_java_gov_nasa_arc_mct_fastplot_view_PlotSettingsControlPanel.java |
769 | nonTimeMaxFixedMode.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if(nonTimeMaxFixedMode.isSelected()) {
nonTimeMaxSemiFixedMode.setEnabled(true);
} else {
nonTimeMaxSemiFixedMode.setEnabled(false);
nonTimeMaxSemiFixedMode.setSelected(false);
}
}
}); | false | fastPlotViews_src_main_java_gov_nasa_arc_mct_fastplot_view_PlotSettingsControlPanel.java |
770 | NumberFormat.getIntegerInstance()) {
protected DocumentFilter getDocumentFilter() {
return filter;
}
private DocumentFilter filter = new PaddingFilter();
}); | false | fastPlotViews_src_main_java_gov_nasa_arc_mct_fastplot_view_PlotSettingsControlPanel.java |
771 | ActionListener buttonListener = new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
updateMainButtons();
}
}; | false | fastPlotViews_src_main_java_gov_nasa_arc_mct_fastplot_view_PlotSettingsControlPanel.java |
772 | tField.addAncestorListener(new AncestorListener() {
@Override
public void ancestorAdded(AncestorEvent event) {
tField.selectAll();
tField.removeAncestorListener(this);
}
@Override
public void ancestorMoved(AncestorEvent event) {
}
@Override
public void ancestorRemoved(AncestorEvent event) {
}
}); | false | fastPlotViews_src_main_java_gov_nasa_arc_mct_fastplot_view_PlotSettingsControlPanel.java |
773 | ActionListener disabler = new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
boolean linesShowing = !markersOnly.isSelected();
connectionLineTypeLabel.setEnabled(linesShowing);
direct.setEnabled(linesShowing);
step.setEnabled(linesShowing);
}
}; | false | fastPlotViews_src_main_java_gov_nasa_arc_mct_fastplot_view_PlotSettingsControlPanel.java |
774 | ActionListener timeAxisListener = new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
updateTimeAxisControls();
}
}; | false | fastPlotViews_src_main_java_gov_nasa_arc_mct_fastplot_view_PlotSettingsControlPanel.java |
775 | timeAxisMinManual.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
timeMinManualHasBeenSelected = true;
updateTimeAxisControls();
}
}); | false | fastPlotViews_src_main_java_gov_nasa_arc_mct_fastplot_view_PlotSettingsControlPanel.java |
776 | timeAxisMaxManual.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
timeMaxManualHasBeenSelected = true;
updateTimeAxisControls();
}
}); | false | fastPlotViews_src_main_java_gov_nasa_arc_mct_fastplot_view_PlotSettingsControlPanel.java |
777 | ActionListener nonTimeAxisListener = new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
updateNonTimeAxisControls();
}
}; | false | fastPlotViews_src_main_java_gov_nasa_arc_mct_fastplot_view_PlotSettingsControlPanel.java |
778 | nonTimeAxisMinManual.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (nonTimeAxisMinManual.isSelected()) {
nonTimeAxisMinManualValue.requestFocusInWindow();
nonTimeAxisMinManualValue.setSelectionStart(0);
String content = nonTimeAxisMinManualValue.getText();
if (content != null) {
nonTimeAxisMinManualValue.setSelectionEnd(content.length());
}
updateNonTimeAxisControls();
}
}
}); | false | fastPlotViews_src_main_java_gov_nasa_arc_mct_fastplot_view_PlotSettingsControlPanel.java |
779 | nonTimeAxisMaxManual.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (nonTimeAxisMaxManual.isSelected()) {
nonTimeAxisMaxManualValue.requestFocusInWindow();
nonTimeAxisMaxManualValue.setSelectionStart(0);
String content = nonTimeAxisMaxManualValue.getText();
if (content != null) {
nonTimeAxisMaxManualValue.setSelectionEnd(content.length());
}
updateNonTimeAxisControls();
}
}
}); | false | fastPlotViews_src_main_java_gov_nasa_arc_mct_fastplot_view_PlotSettingsControlPanel.java |
780 | public static class CalendarDump {
public static String dumpDateAndTime(GregorianCalendar calendar) {
StringBuilder buffer = new StringBuilder();
buffer.append(calendar.get(Calendar.YEAR) + " - ");
buffer.append(calendar.get(Calendar.DAY_OF_YEAR) + "/");
buffer.append(calendar.get(Calendar.HOUR_OF_DAY) + ":");
buffer.append(calendar.get(Calendar.MINUTE) + ":");
buffer.append(calendar.get(Calendar.SECOND));
buffer.append(", Zone " + (calendar.get(Calendar.ZONE_OFFSET) / (3600 * 1000)));
return buffer.toString();
}
public static String dumpMillis(long timeInMillis) {
GregorianCalendar cal = new GregorianCalendar();
cal.setTimeInMillis(timeInMillis);
return dumpDateAndTime(cal);
}
} | false | fastPlotViews_src_main_java_gov_nasa_arc_mct_fastplot_view_PlotSettingsControlPanel.java |
781 | static class GridLinedPanel extends JPanel {
private static final long serialVersionUID = -1227455333903006294L;
private GridBagConstraints wrapGbc;
public GridLinedPanel() {
setLayout(new GridBagLayout());
setBorder(BorderFactory.createLineBorder(Color.gray));
}
void setGBC(GridBagConstraints inputGbc) {
wrapGbc = inputGbc;
}
// Wrap each added ui control in a JPanel with a border
void addCell(JLabel uiControl, int xPosition, int yPosition) {
uiControl.setHorizontalAlignment(JLabel.CENTER);
wrapControlInPanel(uiControl, xPosition, yPosition);
}
// Wrap each added ui control in a JPanel with a border
void addCell(JPanel uiControl, int xPosition, int yPosition) {
wrapControlInPanel(uiControl, xPosition, yPosition);
}
private void wrapControlInPanel(JComponent uiControl, int xPosition,
int yPosition) {
JPanel wrapperPanel = new JPanel();
wrapperPanel.setLayout(new GridBagLayout());
GridBagConstraints gbc = new GridBagConstraints();
wrapperPanel.add(uiControl, gbc);
wrapGbc.gridx = xPosition;
wrapGbc.gridy = yPosition;
wrapperPanel.setBorder(new LineBorder(Color.lightGray));
add(wrapperPanel, wrapGbc);
}
private void addCell(JComponent uiControl, int xPosition,
int yPosition, int alignment) {
JPanel wrapperPanel = new JPanel(new GridBagLayout());
wrapperPanel.setBorder(new LineBorder(Color.lightGray));
GridBagConstraints gbc = new GridBagConstraints();
if (alignment == GridBagConstraints.WEST) {
gbc.weightx = 1;
gbc.anchor = GridBagConstraints.WEST;
}
wrapperPanel.add(uiControl, gbc);
wrapGbc.gridx = xPosition;
wrapGbc.gridy = yPosition;
add(wrapperPanel, wrapGbc);
}
} | false | fastPlotViews_src_main_java_gov_nasa_arc_mct_fastplot_view_PlotSettingsControlPanel.java |
782 | class NonTimeAxisMaximumsPanel extends JPanel {
private static final long serialVersionUID = -768623994853270825L;
public NonTimeAxisMaximumsPanel() {
setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
nonTimeAxisMaxCurrent = new JRadioButton(BUNDLE.getString("CurrentLargestDatum.label"), true);
nonTimeAxisMaxCurrentValue = new ParenthesizedNumericLabel(nonTimeAxisMaxCurrent);
nonTimeAxisMaxCurrentValue.setValue(1.0);
nonTimeAxisMaxManual = new JRadioButton(MANUAL_LABEL, false);
DecimalFormat format = new DecimalFormat("###.######");
format.setParseIntegerOnly(false);
nonTimeAxisMaxManualValue = new NumericTextField(NUMERIC_TEXTFIELD_COLS1, format);
nonTimeAxisMaxManualValue.setColumns(JTEXTFIELD_COLS);
nonTimeAxisMaxManualValue.setText(nonTimeAxisMaxCurrentValue.getValue().toString());
nonTimeAxisMaxAutoAdjust = new JRadioButton(BUNDLE.getString("MinPlusSpan.label"), false);
nonTimeAxisMaxAutoAdjustValue = new ParenthesizedNumericLabel(nonTimeAxisMaxAutoAdjust);
nonTimeAxisMaxAutoAdjustValue.setValue(1.0);
JPanel xAxisMaxRow1 = createMultiItemRow(nonTimeAxisMaxCurrent, nonTimeAxisMaxCurrentValue);
JPanel xAxisMaxRow2 = createMultiItemRow(nonTimeAxisMaxManual, nonTimeAxisMaxManualValue);
JPanel xAxisMaxRow3 = createMultiItemRow(nonTimeAxisMaxAutoAdjust, nonTimeAxisMaxAutoAdjustValue);
ButtonGroup maximumsGroup = new ButtonGroup();
maximumsGroup.add(nonTimeAxisMaxManual);
maximumsGroup.add(nonTimeAxisMaxCurrent);
maximumsGroup.add(nonTimeAxisMaxAutoAdjust);
// Layout
add(xAxisMaxRow1);
add(xAxisMaxRow2);
add(xAxisMaxRow3);
nonTimeAxisMaxCurrent.setToolTipText(BUNDLE.getString("NonTimeAxisMax.label"));
// Instrument
xAxisMaxRow1.setName("xAxisMaxRow1");
xAxisMaxRow2.setName("xAxisMaxRow2");
xAxisMaxRow3.setName("xAxisMaxRow3");
}
} | false | fastPlotViews_src_main_java_gov_nasa_arc_mct_fastplot_view_PlotSettingsControlPanel.java |
783 | class NonTimeAxisMinimumsPanel extends JPanel {
private static final long serialVersionUID = -2619634570876465687L;
public NonTimeAxisMinimumsPanel() {
setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
nonTimeAxisMinCurrent = new JRadioButton(BUNDLE.getString("CurrentSmallestDatum.label"), true);
nonTimeAxisMinCurrentValue = new ParenthesizedNumericLabel(nonTimeAxisMinCurrent);
nonTimeAxisMinCurrentValue.setValue(0.0);
nonTimeAxisMinManual = new JRadioButton(MANUAL_LABEL, false);
nonTimeAxisMinManualValue = new NumericTextField(NUMERIC_TEXTFIELD_COLS1, nonTimePaddingFormat);
nonTimeAxisMinManualValue.setColumns(JTEXTFIELD_COLS);
nonTimeAxisMinManualValue.setText(nonTimeAxisMinCurrentValue.getValue().toString());
nonTimeAxisMinAutoAdjust = new JRadioButton(BUNDLE.getString("MaxMinusSpan.label"), false);
nonTimeAxisMinAutoAdjustValue = new ParenthesizedNumericLabel(nonTimeAxisMinAutoAdjust);
nonTimeAxisMinAutoAdjustValue.setValue(0.0);
JPanel xAxisMinRow1 = createMultiItemRow(nonTimeAxisMinCurrent, nonTimeAxisMinCurrentValue);
JPanel xAxisMinRow2 = createMultiItemRow(nonTimeAxisMinManual, nonTimeAxisMinManualValue);
JPanel xAxisMinRow3 = createMultiItemRow(nonTimeAxisMinAutoAdjust, nonTimeAxisMinAutoAdjustValue);
ButtonGroup minimumsGroup = new ButtonGroup();
minimumsGroup.add(nonTimeAxisMinCurrent);
minimumsGroup.add(nonTimeAxisMinManual);
minimumsGroup.add(nonTimeAxisMinAutoAdjust);
// Layout
add(xAxisMinRow1);
add(xAxisMinRow2);
add(xAxisMinRow3);
nonTimeAxisMinCurrent.setToolTipText(BUNDLE.getString("NonTimeAxisMin.label"));
// Instrument
xAxisMinRow1.setName("xAxisMinRow1");
xAxisMinRow2.setName("xAxisMinRow2");
xAxisMinRow3.setName("xAxisMinRow3");
}
} | false | fastPlotViews_src_main_java_gov_nasa_arc_mct_fastplot_view_PlotSettingsControlPanel.java |
784 | class NonTimeFieldFocusListener extends FocusAdapter {
private JRadioButton companionButton;
public NonTimeFieldFocusListener(JRadioButton assocButton) {
companionButton = assocButton;
}
@Override
public void focusGained(FocusEvent e) {
if (e.isTemporary())
return;
companionButton.setSelected(true);
updateNonTimeAxisControls();
}
@Override
public void focusLost(FocusEvent e) {
if (e.isTemporary())
return;
updateNonTimeAxisControls();
}
} | false | fastPlotViews_src_main_java_gov_nasa_arc_mct_fastplot_view_PlotSettingsControlPanel.java |
785 | class PaddingFilter extends DocumentFilter {
private StringBuilder insertBuilder;
private StringBuilder replaceBuilder;
@Override
public void insertString(FilterBypass fb, int offset, String string, AttributeSet attr)
throws BadLocationException {
insertBuilder = new StringBuilder(string);
for (int k = insertBuilder.length() - 1; k >= 0; k--) {
int cp = insertBuilder.codePointAt(k);
if (! Character.isDigit(cp)) {
insertBuilder.deleteCharAt(k);
if (Character.isSupplementaryCodePoint(cp)) {
k--;
insertBuilder.deleteCharAt(k);
}
}
}
super.insertString(fb, offset, insertBuilder.toString(), attr);
}
@Override
public void replace(FilterBypass fb, int offset, int length, String string, AttributeSet attr)
throws BadLocationException {
replaceBuilder = new StringBuilder(string);
for (int k = replaceBuilder.length() - 1; k >= 0; k--) {
int cp = replaceBuilder.codePointAt(k);
if (! Character.isDigit(cp)) {
replaceBuilder.deleteCharAt(k);
if (Character.isSupplementaryCodePoint(cp)) {
k--;
replaceBuilder.deleteCharAt(k);
}
}
}
super.replace(fb, offset, length, replaceBuilder.toString(), attr);
}
StringBuilder getInsertBuilder() {
return insertBuilder;
}
StringBuilder getReplaceBuilder() {
return replaceBuilder;
}
} | false | fastPlotViews_src_main_java_gov_nasa_arc_mct_fastplot_view_PlotSettingsControlPanel.java |
786 | class ParenthesizedNumericLabel extends JLabel {
private static final long serialVersionUID = 3403375470853249483L;
private JRadioButton companionButton;
public ParenthesizedNumericLabel(JRadioButton button) {
companionButton = button;
this.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
companionButton.setSelected(true);
companionButton.requestFocusInWindow();
updateMainButtons();
}
});
}
public Double getValue() {
String data = getText();
if (data == null) {
return null;
}
if (data.length() < 3) {
logger.error("Numeric label in plot settings contained invalid content [" + data + "]");
return null;
}
Double result = null;
try {
result = Double.parseDouble(data.substring(1, data.length() - 1));
} catch(NumberFormatException e) {
logger.error("Could not parse numeric value from ["+ data.substring(1, data.length() - 1) + "]");
}
return result;
}
public void setValue(Double input) {
String formatNum = nonTimePaddingFormat.format(input);
if (formatNum.equals("0"))
formatNum = "0.0";
if (formatNum.equals("1"))
formatNum = "1.0";
setText("(" + formatNum + ")");
}
} | false | fastPlotViews_src_main_java_gov_nasa_arc_mct_fastplot_view_PlotSettingsControlPanel.java |
787 | this.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
companionButton.setSelected(true);
companionButton.requestFocusInWindow();
updateMainButtons();
}
}); | false | fastPlotViews_src_main_java_gov_nasa_arc_mct_fastplot_view_PlotSettingsControlPanel.java |
788 | class ParenthesizedTimeLabel extends JLabel {
private static final long serialVersionUID = -6004293775277749905L;
private GregorianCalendar timeInMillis;
private JRadioButton companionButton;
public ParenthesizedTimeLabel(JRadioButton button) {
companionButton = button;
this.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
companionButton.setSelected(true);
companionButton.requestFocusInWindow();
updateMainButtons();
}
});
}
public void setTime(GregorianCalendar inputTime) {
timeInMillis = inputTime;
setText("(" + dateFormat.format(inputTime.getTime()) + ")");
}
public GregorianCalendar getCalendar() {
return timeInMillis;
}
public long getTimeInMillis() {
return timeInMillis.getTimeInMillis();
}
public String getSavedTime() {
return CalendarDump.dumpDateAndTime(timeInMillis);
}
public int getSecond() {
return timeInMillis.get(Calendar.SECOND);
}
public int getMinute() {
return timeInMillis.get(Calendar.MINUTE);
}
public int getHourOfDay() {
return timeInMillis.get(Calendar.HOUR_OF_DAY);
}
} | false | fastPlotViews_src_main_java_gov_nasa_arc_mct_fastplot_view_PlotSettingsControlPanel.java |
789 | this.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
companionButton.setSelected(true);
companionButton.requestFocusInWindow();
updateMainButtons();
}
}); | false | fastPlotViews_src_main_java_gov_nasa_arc_mct_fastplot_view_PlotSettingsControlPanel.java |
790 | @SuppressWarnings("serial")
static public class SectionPanel extends JPanel {
public SectionPanel(String titleText, JPanel inputPanel) {
setLayout(new GridBagLayout());
GridBagConstraints gbc = new GridBagConstraints();
gbc.weightx = 1.0;
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.gridwidth = GridBagConstraints.REMAINDER;
setBorder(BorderFactory.createTitledBorder(titleText));
add(inputPanel, gbc);
JLabel padding = new JLabel();
gbc.weighty = 1.0;
add(padding, gbc);
}
} | false | fastPlotViews_src_main_java_gov_nasa_arc_mct_fastplot_view_PlotSettingsControlPanel.java |
791 | public class StillPlotImagePanel extends JPanel {
private static final long serialVersionUID = 8645833372400367908L;
private JLabel timeOnXAxisNormalPicture;
private JLabel timeOnYAxisNormalPicture;
private JLabel timeOnXAxisReversedPicture;
private JLabel timeOnYAxisReversedPicture;
public StillPlotImagePanel() {
timeOnXAxisNormalPicture = new JLabel("", IconLoader.INSTANCE.getIcon(IconLoader.Icons.PLOT_TIME_ON_X_NORMAL), JLabel.CENTER);
timeOnYAxisNormalPicture = new JLabel("", IconLoader.INSTANCE.getIcon(IconLoader.Icons.PLOT_TIME_ON_Y_NORMAL), JLabel.CENTER);
timeOnXAxisReversedPicture = new JLabel("", IconLoader.INSTANCE.getIcon(IconLoader.Icons.PLOT_TIME_ON_X_REVERSED), JLabel.CENTER);
timeOnYAxisReversedPicture = new JLabel("", IconLoader.INSTANCE.getIcon(IconLoader.Icons.PLOT_TIME_ON_Y_REVERSED), JLabel.CENTER);
add(timeOnXAxisNormalPicture); // default
// Instrument
timeOnXAxisNormalPicture.setName("timeOnXAxisNormalPicture");
timeOnYAxisNormalPicture.setName("timeOnYAxisNormalPicture");
timeOnXAxisReversedPicture.setName("timeOnXAxisReversedPicture");
timeOnYAxisReversedPicture.setName("timeOnYAxisReversedPicture");
}
public void setImageToTimeOnXAxis(boolean normalDirection) {
removeAll();
if (normalDirection) {
add(timeOnXAxisNormalPicture);
} else {
add(timeOnXAxisReversedPicture);
}
revalidate();
}
public void setImageToTimeOnYAxis(boolean normalDirection) {
removeAll();
if (normalDirection) {
add(timeOnYAxisNormalPicture);
} else {
add(timeOnYAxisReversedPicture);
}
revalidate();
}
} | false | fastPlotViews_src_main_java_gov_nasa_arc_mct_fastplot_view_PlotSettingsControlPanel.java |
792 | class TimeAxisMaximumsPanel extends JPanel {
private static final long serialVersionUID = 6105026690366452860L;
public TimeAxisMaximumsPanel() {
setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
timeAxisMaxCurrent = new JRadioButton(BUNDLE.getString("CurrentMax.label"));
timeAxisMaxCurrentValue = new ParenthesizedTimeLabel(timeAxisMaxCurrent);
GregorianCalendar initCalendar = new GregorianCalendar();
initCalendar.add(Calendar.MINUTE, 10);
timeAxisMaxCurrentValue.setTime(initCalendar);
timeAxisMaxManual = new JRadioButton(MANUAL_LABEL);
MaskFormatter formatter = null;
try {
formatter = new MaskFormatter("###/##:##:##");
formatter.setPlaceholderCharacter('0');
} catch (ParseException e) {
e.printStackTrace();
}
timeAxisMaxManualValue = new TimeTextField(formatter);
initCalendar.setTimeInMillis(timeAxisMaxManualValue.getValueInMillis() + 1000);
timeAxisMaxManualValue.setTime(initCalendar);
timeAxisMaxAuto = new JRadioButton(BUNDLE.getString("MinPlusSpan.label"));
timeAxisMaxAutoValue = new ParenthesizedTimeLabel(timeAxisMaxAuto);
timeAxisMaxAutoValue.setTime(initCalendar);
JPanel yAxisMaxRow1 = createMultiItemRow(timeAxisMaxCurrent, timeAxisMaxCurrentValue);
JPanel yAxisMaxRow2 = createMultiItemRow(timeAxisMaxManual, timeAxisMaxManualValue);
JPanel yAxisMaxRow3 = createMultiItemRow(timeAxisMaxAuto, timeAxisMaxAutoValue);
timeAxisMaxAuto.setSelected(true);
add(yAxisMaxRow1);
add(yAxisMaxRow2);
add(yAxisMaxRow3);
add(Box.createVerticalGlue());
ButtonGroup maxButtonGroup = new ButtonGroup();
maxButtonGroup.add(timeAxisMaxCurrent);
maxButtonGroup.add(timeAxisMaxManual);
maxButtonGroup.add(timeAxisMaxAuto);
timeAxisMaxAuto.setToolTipText(BUNDLE.getString("TimeAxisMins.label"));
}
} | false | fastPlotViews_src_main_java_gov_nasa_arc_mct_fastplot_view_PlotSettingsControlPanel.java |
793 | class TimeAxisMinimumsPanel extends JPanel {
private static final long serialVersionUID = 3651502189841560982L;
public TimeAxisMinimumsPanel() {
setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
timeAxisMinCurrent = new JRadioButton(BUNDLE.getString("Currentmin.label"));
timeAxisMinCurrentValue = new ParenthesizedTimeLabel(timeAxisMinCurrent);
timeAxisMinCurrentValue.setTime(new GregorianCalendar());
timeAxisMinManual = new JRadioButton(MANUAL_LABEL);
MaskFormatter formatter = null;
try {
formatter = new MaskFormatter("###/##:##:##");
formatter.setPlaceholderCharacter('0');
} catch (ParseException e) {
logger.error("Parse error in creating time field", e);
}
timeAxisMinManualValue = new TimeTextField(formatter);
timeAxisMinAuto = new JRadioButton(BUNDLE.getString("Now.label"));
timeAxisMinAutoValue = new ParenthesizedTimeLabel(timeAxisMinAuto);
timeAxisMinAutoValue.setTime(new GregorianCalendar());
timeAxisMinAutoValue.setText("should update every second");
timeAxisMinAuto.setSelected(true);
JPanel yAxisMinRow1 = createMultiItemRow(timeAxisMinCurrent, timeAxisMinCurrentValue);
JPanel yAxisMinRow2 = createMultiItemRow(timeAxisMinManual, timeAxisMinManualValue);
JPanel yAxisMinRow3 = createMultiItemRow(timeAxisMinAuto, timeAxisMinAutoValue);
add(yAxisMinRow1);
add(yAxisMinRow2);
add(yAxisMinRow3);
add(Box.createVerticalGlue());
ButtonGroup minButtonGroup = new ButtonGroup();
minButtonGroup.add(timeAxisMinCurrent);
minButtonGroup.add(timeAxisMinManual);
minButtonGroup.add(timeAxisMinAuto);
timeAxisMinAuto.setToolTipText(BUNDLE.getString("TimeAxisMins.label"));
}
} | false | fastPlotViews_src_main_java_gov_nasa_arc_mct_fastplot_view_PlotSettingsControlPanel.java |
794 | class TimeAxisModeListener implements ActionListener {
private JTextComponent companionField;
public TimeAxisModeListener(JTextComponent field) {
companionField = field;
}
@Override
public void actionPerformed(ActionEvent e) {
updateMainButtons();
String content = companionField.getText();
companionField.requestFocusInWindow();
companionField.setSelectionStart(0);
if (content != null) {
companionField.setSelectionEnd(content.length());
}
}
} | false | fastPlotViews_src_main_java_gov_nasa_arc_mct_fastplot_view_PlotSettingsControlPanel.java |
795 | class TimeFieldFocusListener extends FocusAdapter {
// This class can be used with a null button
private JRadioButton companionButton;
public TimeFieldFocusListener(JRadioButton assocButton) {
companionButton = assocButton;
}
@Override
public void focusGained(FocusEvent e) {
if (e.isTemporary())
return;
if (companionButton != null) {
companionButton.setSelected(true);
}
updateMainButtons();
}
@Override
public void focusLost(FocusEvent e) {
if (e.isTemporary())
return;
try {
timeSpanValue.commitEdit();
} catch (ParseException exception) {
exception.printStackTrace();
}
updateTimeAxisControls();
}
} | false | fastPlotViews_src_main_java_gov_nasa_arc_mct_fastplot_view_PlotSettingsControlPanel.java |
796 | class TimePaddingFocusListener extends FocusAdapter {
@Override
public void focusLost(FocusEvent e) {
if (e.isTemporary())
return;
updateTimeAxisControls();
}
} | false | fastPlotViews_src_main_java_gov_nasa_arc_mct_fastplot_view_PlotSettingsControlPanel.java |
797 | class XAxisAdjacentPanel extends JPanel {
private static final long serialVersionUID = 4160271246055659710L;
GridBagConstraints gbcLeft = new GridBagConstraints();
GridBagConstraints gbcRight = new GridBagConstraints();
GridBagConstraints gbcCenter = new GridBagConstraints();
public XAxisAdjacentPanel() {
this.setLayout(new GridBagLayout());
xMinLabel = new JLabel(BUNDLE.getString("Min.label"));
xMaxLabel = new JLabel(BUNDLE.getString("Max.label"));
xMinLabel.setFont(xMinLabel.getFont().deriveFont(Font.BOLD));
xMaxLabel.setFont(xMaxLabel.getFont().deriveFont(Font.BOLD));
setBorder(BOTTOM_PADDED_MARGINS);
gbcLeft.anchor = GridBagConstraints.WEST;
gbcLeft.gridx = 0;
gbcLeft.gridy = 0;
gbcLeft.weightx = 0.5;
gbcCenter.anchor = GridBagConstraints.NORTH;
gbcCenter.gridx = 1;
gbcCenter.gridy = 0;
gbcRight.anchor = GridBagConstraints.EAST;
gbcRight.gridx = 2;
gbcRight.gridy = 0;
gbcRight.weightx = 0.5;
}
public void setNormalOrder(boolean normalDirection) {
removeAll();
if (normalDirection) {
add(xMinLabel, gbcLeft);
add(xAxisSpanCluster, gbcCenter);
add(xMaxLabel, gbcRight);
} else {
add(xMaxLabel, gbcLeft);
add(xAxisSpanCluster, gbcCenter);
add(xMinLabel, gbcRight);
}
revalidate();
}
} | false | fastPlotViews_src_main_java_gov_nasa_arc_mct_fastplot_view_PlotSettingsControlPanel.java |
798 | class XAxisButtonsPanel extends JPanel {
private static final long serialVersionUID = -5671943216161507045L;
private JPanel minimumsPanel;
private JPanel maximumsPanel;
private GridBagConstraints gbcLeft;
private GridBagConstraints gbcRight;
public XAxisButtonsPanel() {
this.setLayout(new GridBagLayout());
gbcLeft = new GridBagConstraints();
gbcLeft.gridx = 0;
gbcLeft.gridy = 0;
gbcLeft.fill = GridBagConstraints.BOTH;
gbcLeft.anchor = GridBagConstraints.WEST;
gbcLeft.weightx = 1;
gbcRight = new GridBagConstraints();
gbcRight.gridx = 1;
gbcRight.gridy = 0;
gbcRight.fill = GridBagConstraints.BOTH;
gbcLeft.anchor = GridBagConstraints.EAST;
gbcRight.weightx = 1;
}
public void setNormalOrder(boolean normalDirection) {
removeAll();
if (normalDirection) {
add(minimumsPanel, gbcLeft);
add(maximumsPanel, gbcRight);
} else {
add(maximumsPanel, gbcLeft);
add(minimumsPanel, gbcRight);
}
revalidate();
}
public void insertMinMaxPanels(JPanel minPanel, JPanel maxPanel) {
minimumsPanel = minPanel;
maximumsPanel = maxPanel;
}
} | false | fastPlotViews_src_main_java_gov_nasa_arc_mct_fastplot_view_PlotSettingsControlPanel.java |
799 | class XAxisSpanCluster extends JPanel {
private static final long serialVersionUID = -3947426156383446643L;
private JComponent spanValue;
private JLabel spanTag;
private Component boxStrut;
public XAxisSpanCluster() {
setLayout(new BoxLayout(this, BoxLayout.X_AXIS));
spanTag = new JLabel("Span: ");
// Create a text field with a ddd/hh:mm:ss format for time
MaskFormatter formatter = null;
try {
formatter = new MaskFormatter("###/##:##:##");
formatter.setPlaceholderCharacter('0');
} catch (ParseException e) {
logger.error("Error in creating a mask formatter", e);
}
timeSpanValue = new TimeSpanTextField(formatter);
spanValue = timeSpanValue;
boxStrut = Box.createHorizontalStrut(INTERCONTROL_HORIZONTAL_SPACING);
layoutPanel();
// Instrument
spanTag.setName("spanTag");
}
void layoutPanel() {
removeAll();
add(spanTag);
add(boxStrut);
add(spanValue);
}
void setSpanField(JComponent field) {
spanValue = field;
layoutPanel();
}
} | false | fastPlotViews_src_main_java_gov_nasa_arc_mct_fastplot_view_PlotSettingsControlPanel.java |