下面列出了javax.swing.JSplitPane#HORIZONTAL_SPLIT 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/**
* Creates the GUI.
*/
protected void createGUI() {
fourierManager = new DatasetManager();
fourierManager.setXPointsLinked(true);
table = new DataTable();
table.add(fourierManager);
plot = new PlottingPanel("", "", ""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
plotPanel = new JPanel(new BorderLayout());
plotPanel.add(plot, BorderLayout.CENTER);
splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
splitPane.setResizeWeight(1);
JScrollPane scroller = new JScrollPane(table);
splitPane.setRightComponent(scroller);
splitPane.setLeftComponent(plotPanel);
add(splitPane, BorderLayout.CENTER);
}
/**
* overrides to hardcode the size of the divider
* PENDING(jeff) - rewrite JSplitPane so that this ins't needed
*/
public void setDividerSize(int newSize) {
Insets insets = getInsets();
int borderSize = 0;
if (getBasicSplitPaneUI().getOrientation() ==
JSplitPane.HORIZONTAL_SPLIT) {
if (insets != null) {
borderSize = insets.left + insets.right;
}
}
else if (insets != null) {
borderSize = insets.top + insets.bottom;
}
if (newSize < pad + minimumThumbSize + borderSize) {
setDividerSize(pad + minimumThumbSize + borderSize);
} else {
vThumbHeight = hThumbWidth = newSize - pad - borderSize;
super.setDividerSize(newSize);
}
}
private void computeDividerLocationWhenHidden(Component hiddenComponent) {
if (getTopComponent().isVisible() || getBottomComponent().isVisible()) {
if (getOrientation() == JSplitPane.HORIZONTAL_SPLIT) {
if (hiddenComponent == getFirstComponent()) {
dividerLocation = hiddenComponent.getSize().width / (getSize().getWidth() - dividerSize);
} else {
dividerLocation = (getSize().getWidth() - dividerSize - hiddenComponent.getSize().width) / (getSize()
.getWidth()
- dividerSize);
}
} else {
if (hiddenComponent == getFirstComponent()) {
dividerLocation = hiddenComponent.getSize().height / (getSize().getHeight() - dividerSize);
} else {
dividerLocation = (getSize().getHeight() - dividerSize - hiddenComponent.getSize().height) / (getSize()
.getHeight()
- dividerSize);
}
}
dividerLocation = Math.max(0, dividerLocation);
dividerLocation = Math.min(1, dividerLocation);
}
}
/**
* Init the component
*/
private void init() {
if (!Env.INSTANCE.isOpenGLAvailable()) {
LOGGER.warn("No graphic card that supports required OpenGL features has been detected. The 3D map will be not be available");
}
ToolTipManager.sharedInstance().setInitialDelay(0);
// init panels
_statusPanel = new StatusPanel(_services);
_replayPanel = new ReplayPanel(_services, _statusPanel);
_controlPanel = new ControlPanel(_services, this, _replayPanel, Env.INSTANCE.isIs3dMap(), Env.INSTANCE.getMode());
_split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
_rightSplit = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
_rightPanel = new JPanel(new BorderLayout());
_rightPanel.add(_rightSplit, BorderLayout.CENTER);
_rightPanel.add(_statusPanel, BorderLayout.SOUTH);
_split.setRightComponent(_rightPanel);
createRightView();
createMap(false);
add(_split, BorderLayout.CENTER);
// add header
add(_controlPanel, BorderLayout.NORTH);
resizeSplit();
}
@Override
public Dimension getPreferredSize() {
if (this.orientation == JSplitPane.HORIZONTAL_SPLIT) {
return new Dimension(getDividerSize(), 5);
} else {
return new Dimension(5, getDividerSize());
}
}
private void initComponents() {
setLayout(new BorderLayout());
final JPanel staticFieldsBrowserPanel = classesController.getStaticFieldsBrowserController().getPanel();
staticFieldsBrowserPanel.setPreferredSize(new Dimension(250, 500));
staticFieldsBrowserPanel.setVisible(false);
contentsSplit = new JExtendedSplitPane(JSplitPane.HORIZONTAL_SPLIT,
classesController.getClassesListController().getPanel(), staticFieldsBrowserPanel);
contentsSplit.setResizeWeight(1d);
final JPanel legendPanel = new LegendPanel(false);
legendPanel.setVisible(false);
tweakSplitPaneUI(contentsSplit);
add(contentsSplit, BorderLayout.CENTER);
add(legendPanel, BorderLayout.SOUTH);
staticFieldsBrowserPanel.addHierarchyListener(new HierarchyListener() {
public void hierarchyChanged(HierarchyEvent e) {
if ((e.getChangeFlags() & HierarchyEvent.SHOWING_CHANGED) != 0) {
legendPanel.setVisible(staticFieldsBrowserPanel.isShowing());
}
}
});
}
private void computeDividerLocationWhenHidden(Component hiddenComponent) {
if (leftComponent.isVisible() || rightComponent.isVisible()) {
boolean horiz = getOrientation() == JSplitPane.HORIZONTAL_SPLIT;
double size = horiz ? getSize().getWidth() :
getSize().getHeight();
double csize = horiz ? hiddenComponent.getSize().getWidth() :
hiddenComponent.getSize().getHeight();
computeDividerLocation(hiddenComponent, size, csize);
}
}
/**
* Initialize the GUI panel
* @return
*/
private JSplitPane buildSplitPane() {
final JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
splitPane.setLeftComponent(getLeftPanel());
splitPane.setOneTouchExpandable(true);
splitPane.setDividerLocation(150);
return splitPane;
}
private void situateNotElongated() {
JPanel cp = new JPanel(new BorderLayout());
cp.add(sp);
cp.add(errorStrip, BorderLayout.LINE_END);
cp.setBorder(BorderFactory.createEtchedBorder());
JComponent newtop = cp;
if (enable_outline) {
JSplitPane xx2 = new Split(.8, JSplitPane.HORIZONTAL_SPLIT);
xx2.setDividerSize(6);
if (outline_on_left) {
xx2.setResizeWeight(.2);
xx2.add(p);
xx2.add(cp);
} else {
xx2.setResizeWeight(.8);
xx2.add(cp);
xx2.add(p);
}
xx2.setBorder(BorderFactory.createEmptyBorder());
newtop = xx2;
}
JSplitPane xx1 = new Split(.8, JSplitPane.VERTICAL_SPLIT);
xx1.setDividerSize(6);
xx1.setResizeWeight(.8);
xx1.add(newtop);
xx1.add(respAreaX);
xx1.setBorder(BorderFactory.createEmptyBorder());
respAreaX.setMinimumSize(new Dimension(0, 0));
this.removeAll();
add(xx1);
revalidate();
}
@Override
public void init() {
Insets insets = new Insets(10, 10, 10, 10);
Dimension size = new Dimension(getWidth() / 2, getHeight());
JSplitPane pane = new JSplitPane(
JSplitPane.HORIZONTAL_SPLIT,
create("Color", size, new MatteBorder(insets, RED)),
create("Icon", size, new MatteBorder(insets, this)));
pane.setDividerLocation(size.width - pane.getDividerSize() / 2);
add(pane);
}
@Override
public void init() {
Insets insets = new Insets(10, 10, 10, 10);
Dimension size = new Dimension(getWidth() / 2, getHeight());
JSplitPane pane = new JSplitPane(
JSplitPane.HORIZONTAL_SPLIT,
create("Color", size, new MatteBorder(insets, RED)),
create("Icon", size, new MatteBorder(insets, this)));
pane.setDividerLocation(size.width - pane.getDividerSize() / 2);
add(pane);
}
private JSplitPane addTicPlot(PeakListRow row) {
JSplitPane pane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
// labels for TIC visualizer
Map<Feature, String> labelsMap = new HashMap<Feature, String>(0);
// scan selection
ScanSelection scanSelection = new ScanSelection(rawFiles[0].getDataRTRange(1), 1);
// mz range
Range<Double> mzRange = null;
mzRange = feature.getRawDataPointsMZRange();
// optimize output by extending the range
double upper = mzRange.upperEndpoint();
double lower = mzRange.lowerEndpoint();
double fiveppm = (upper * 5E-6);
mzRange = Range.closed(lower - fiveppm, upper + fiveppm);
// labels
labelsMap.put(feature, feature.toString());
TICVisualizerWindow window = new TICVisualizerWindow(rawFiles, // raw
TICPlotType.BASEPEAK, // plot type
scanSelection, // scan selection
mzRange, // mz range
row.getPeaks(), // selected features
labelsMap); // labels
pane.add(window.getTICPlot());
pane.add(window.getToolBar());
pane.setResizeWeight(1);
pane.setDividerSize(1);
pane.setBorder(BorderFactory.createLineBorder(Color.black));
return pane;
}
/**
* Creates a new debug event list panel where debug events are displayed.
*
* @param eventListManager Provides the event lists that are displayed in this panel.
*/
public CDebugEventListPanel(final ITraceListProvider eventListManager) {
super(new BorderLayout());
Preconditions.checkNotNull(
eventListManager, "IE01369: Event list manager argument can't be null");
// Create the table that shows the recorded event lists.
m_tracesTable = new CEventListTable(eventListManager);
// Add a selection listener that updates the right table
// if the selection in the left table changes.
m_tracesTable.getSelectionModel().addListSelectionListener(new InternalSelectionListener());
final JPanel rightPanel = new JPanel(new BorderLayout());
m_traceEventTable = new CEventTable(new CEventTableModel());
m_traceEventTable.getSelectionModel()
.addListSelectionListener(new InternalEventSelectionListener());
final CTablePanel<ITraceEvent> filteredPanel = new CTraceEventsPanel(m_traceEventTable);
m_eventValueTable = new CEventValueTable(m_eventModel);
m_eventValueTable.addMouseListener(new InternalMouseListener());
final JSplitPane splitPane1 = new JSplitPane(
JSplitPane.HORIZONTAL_SPLIT, true, filteredPanel, new JScrollPane(m_eventValueTable));
rightPanel.add(splitPane1, BorderLayout.CENTER);
splitPane1.setResizeWeight(0.5);
m_tracesPanel = new CTracesPanel(m_tracesTable);
final JSplitPane splitPane =
new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, m_tracesPanel, rightPanel);
add(splitPane, BorderLayout.CENTER);
splitPane.setResizeWeight(0.5);
}
protected JSplitPane getObject() {
return new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
}
/**
* Creates a new ScoreTree object.
*
* @param score the related score
*/
public ScoreTree (Score score)
{
this.score = score;
component = new JPanel();
// Set up the tree
model = new Model(score);
///model.addTreeModelListener(new ModelListener()); // Debug
/** The tree entity */
JTree tree = new JTree(model);
// Build left-side view
JScrollPane treeView = new JScrollPane(tree);
// Build right-side view
htmlPane = new JEditorPane("text/html", "");
htmlPane.setEditable(false);
JScrollPane htmlView = new JScrollPane(htmlPane);
// Allow only single selections
tree.getSelectionModel().setSelectionMode(
TreeSelectionModel.SINGLE_TREE_SELECTION);
// Display lines to explicit relationships
tree.putClientProperty("JTree.lineStyle", "Angled");
// Wire the two views together. Use a selection listener
// created with an anonymous inner-class adapter.
// Listen for when the selection changes.
tree.addTreeSelectionListener(new SelectionListener());
// To be notified of expansion / collapse actions (debug ...)
///tree.addTreeExpansionListener(new ExpansionListener());
// Build split-pane view
JSplitPane splitPane = new JSplitPane(
JSplitPane.HORIZONTAL_SPLIT,
treeView,
htmlView);
splitPane.setName("treeHtmlSplitPane");
splitPane.setContinuousLayout(true);
splitPane.setBorder(null);
splitPane.setDividerSize(2);
// Add GUI components
component.setLayout(new BorderLayout());
component.add("Center", splitPane);
}
@Override
protected void installGUI(JComponent panel) {
panel.addPropertyChangeListener(KEY_INCLUDE_SIDEBAR,
propertyChangeListener);
if (sourceList.isEmpty()) {
File[] array1 = CommonFiles.getUserDirectories(true);
IOLocation[] array2 = new FileLocation[array1.length];
for (int a = 0; a < array1.length; a++) {
array2[a] = LocationFactory.get().create(array1[a]);
}
sourceList.add(array2);
}
boolean includeSidebar = getBoolean(locationPane, KEY_INCLUDE_SIDEBAR,
true);
boolean includeFooter = getBoolean(locationPane, KEY_INCLUDE_FOOTER,
true);
panel.removeAll();
panel.setLayout(new GridBagLayout());
GridBagConstraints c = new GridBagConstraints();
c.gridx = 0;
c.gridy = 0;
c.weightx = 1;
c.weighty = 0;
c.fill = GridBagConstraints.HORIZONTAL;
c.insets = new Insets(4, 0, 4, 0);
panel.add(controls, c);
c.gridy++;
c.weighty = 1;
c.fill = GridBagConstraints.BOTH;
if (includeSidebar) {
splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,
sourceListScrollPane, browser);
panel.add(splitPane, c);
} else {
panel.add(browser, c);
}
if (includeFooter) {
c.weighty = 0;
c.gridy++;
panel.add(footer, c);
}
sourceListScrollPane.setMinimumSize(new Dimension(100, 40));
sourceListScrollPane.setPreferredSize(new Dimension(150, 40));
}
/**
*/
public MainPanel() {
super(new BorderLayout());
// Initialize item selector
rawDataTree = new ProjectTree();
peakListTree = new ProjectTree();
JScrollPane rawDataTreeScroll = new JScrollPane(rawDataTree);
JScrollPane peakListTreeScroll = new JScrollPane(peakListTree);
JSplitPane split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
split.add(rawDataTreeScroll);
split.add(peakListTreeScroll);
split.setResizeWeight(0.5);
split.setMinimumSize(new Dimension(200, 200));
add(split, BorderLayout.CENTER);
taskTable = new TaskProgressTable();
add(taskTable, BorderLayout.SOUTH);
}
protected JSplitPane getObject() {
return new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
}
private Component getHistoryContentPanel() {
JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
splitPane.setLeftComponent(historyTreeView);
splitPane.setRightComponent(getMessagesPanel());
return splitPane;
}
int getSizeInSplit() {
return orientation == JSplitPane.HORIZONTAL_SPLIT ? getComponent().getWidth() : getComponent().getHeight();
}