Java Code Examples for javax.swing.JLayeredPane#getWidth()

The following examples show how to use javax.swing.JLayeredPane#getWidth() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BalloonManager.java    From netbeans with Apache License 2.0 4 votes vote down vote up
private static void configureBalloon( Balloon balloon, JLayeredPane pane, JComponent ownerComp ) {
    Rectangle ownerCompBounds = ownerComp.getBounds();
    ownerCompBounds = SwingUtilities.convertRectangle( ownerComp.getParent(), ownerCompBounds, pane );
    
    int paneWidth = pane.getWidth();
    int paneHeight = pane.getHeight();
    
    Dimension balloonSize = balloon.getPreferredSize();
    balloonSize.height += Balloon.ARC;
    
    //first try lower right corner
    if( ownerCompBounds.x + ownerCompBounds.width + balloonSize.width < paneWidth
        && 
        ownerCompBounds.y + ownerCompBounds.height + balloonSize.height + Balloon.ARC < paneHeight ) {
        
        balloon.setArrowLocation( GridBagConstraints.SOUTHEAST );
        balloon.setBounds( ownerCompBounds.x+ownerCompBounds.width-Balloon.ARC/2, 
                ownerCompBounds.y+ownerCompBounds.height, balloonSize.width+Balloon.ARC, balloonSize.height );
    
    //upper right corner
    } else  if( ownerCompBounds.x + ownerCompBounds.width + balloonSize.width < paneWidth
                && 
                ownerCompBounds.y - balloonSize.height - Balloon.ARC > 0 ) {
        
        balloon.setArrowLocation( GridBagConstraints.NORTHEAST );
        balloon.setBounds( ownerCompBounds.x+ownerCompBounds.width-Balloon.ARC/2, 
                ownerCompBounds.y-balloonSize.height, balloonSize.width+Balloon.ARC, balloonSize.height );
    
    //lower left corner
    } else  if( ownerCompBounds.x - balloonSize.width > 0
                && 
                ownerCompBounds.y + ownerCompBounds.height + balloonSize.height + Balloon.ARC < paneHeight ) {
        
        balloon.setArrowLocation( GridBagConstraints.SOUTHWEST );
        balloon.setBounds( ownerCompBounds.x-balloonSize.width+Balloon.ARC/2, 
                ownerCompBounds.y+ownerCompBounds.height, balloonSize.width+Balloon.ARC, balloonSize.height );
    //upper left corent
    } else {
        balloon.setArrowLocation( GridBagConstraints.NORTHWEST );
        balloon.setBounds( ownerCompBounds.x-balloonSize.width/*+Balloon.ARC/2*/, 
                ownerCompBounds.y-balloonSize.height, balloonSize.width+Balloon.ARC, balloonSize.height );
    }
}
 
Example 2
Source File: BalloonManager.java    From netbeans with Apache License 2.0 4 votes vote down vote up
private static void configureBalloon( Balloon balloon, JLayeredPane pane, JComponent ownerComp ) {
    Rectangle ownerCompBounds = ownerComp.getBounds();
    ownerCompBounds = SwingUtilities.convertRectangle( ownerComp.getParent(), ownerCompBounds, pane );
    
    int paneWidth = pane.getWidth();
    int paneHeight = pane.getHeight();
    
    Dimension balloonSize = balloon.getPreferredSize();
    balloonSize.height += Balloon.ARC;
    
    //first try lower right corner
    if( ownerCompBounds.x + ownerCompBounds.width + balloonSize.width < paneWidth
        && 
        ownerCompBounds.y + ownerCompBounds.height + balloonSize.height + Balloon.ARC < paneHeight ) {
        
        balloon.setArrowLocation( GridBagConstraints.SOUTHEAST );
        balloon.setBounds( ownerCompBounds.x+ownerCompBounds.width-Balloon.ARC/2, 
                ownerCompBounds.y+ownerCompBounds.height, balloonSize.width+Balloon.ARC, balloonSize.height );
    
    //upper right corner
    } else  if( ownerCompBounds.x + ownerCompBounds.width + balloonSize.width < paneWidth
                && 
                ownerCompBounds.y - balloonSize.height - Balloon.ARC > 0 ) {
        
        balloon.setArrowLocation( GridBagConstraints.NORTHEAST );
        balloon.setBounds( ownerCompBounds.x+ownerCompBounds.width-Balloon.ARC/2, 
                ownerCompBounds.y-balloonSize.height, balloonSize.width+Balloon.ARC, balloonSize.height );
    
    //lower left corner
    } else  if( ownerCompBounds.x - balloonSize.width > 0
                && 
                ownerCompBounds.y + ownerCompBounds.height + balloonSize.height + Balloon.ARC < paneHeight ) {
        
        balloon.setArrowLocation( GridBagConstraints.SOUTHWEST );
        balloon.setBounds( ownerCompBounds.x-balloonSize.width+Balloon.ARC/2, 
                ownerCompBounds.y+ownerCompBounds.height, balloonSize.width+Balloon.ARC, balloonSize.height );
    //upper left corent
    } else {
        balloon.setArrowLocation( GridBagConstraints.NORTHWEST );
        balloon.setBounds( ownerCompBounds.x-balloonSize.width/*+Balloon.ARC/2*/, 
                ownerCompBounds.y-balloonSize.height, balloonSize.width+Balloon.ARC, balloonSize.height );
    }
}
 
Example 3
Source File: TimeResolvedAnalysisDataView.java    From ET_Redux with Apache License 2.0 4 votes vote down vote up
private void initSession() {
    setSize(1200, 850);
    SESSION_VIEW_WIDTH = massSpec.getCountOfAcquisitions() * 2;

    rawDataSessionSerialContainer = new RawDataSessionSerialContainer(//
            new Rectangle(0, 0, SESSION_VIEW_WIDTH, rawDataSessionPlotScrollPane.getHeight() - 25), massSpec.getFractionNames());
    // this forces scroll bar
    rawDataSessionSerialContainer.setPreferredSize(rawDataSessionSerialContainer.getSize());
    rawDataSessionSerialContainer.setOpaque(true);
    rawDataSessionSerialContainer.setBackground(Color.white);

    rawDataSessionPlotScrollPane.setViewportView(rawDataSessionSerialContainer);
    rawDataSessionPlotScrollPane.getHorizontalScrollBar().setUnitIncrement(1000);
    rawDataSessionPlotScrollPane.revalidate();

    // overlay of plots
    // need a placeHolderPane
    placeHolderPane = new JLayeredPane();
    placeHolderPane.setBounds(0, 0, rawDataSessionOverlayPlotScrollPane.getWidth() - 5, rawDataSessionOverlayPlotScrollPane.getHeight() - 25);
    placeHolderPane.setPreferredSize(placeHolderPane.getSize());
    rawDataSessionOverlayPlotScrollPane.setViewportView(placeHolderPane);

    rawDataSessionOverlayContainer = new RawDataSessionOverlayContainer(//
            new Rectangle(0, 0, placeHolderPane.getWidth() - 25, placeHolderPane.getHeight() - 25),//
            rawDataSessionSerialContainer);
    rawDataSessionOverlayContainer.setOpaque(true);
    rawDataSessionOverlayContainer.setBackground(Color.white);
    placeHolderPane.add(rawDataSessionOverlayContainer);

    Map<IsotopesEnum, DataModelInterface> isotopeToRawIntensitiesMap = massSpec.getIsotopeMappingModel().getIsotopeToRawIntensitiesMap();
    rawDataSessionPlots = new AbstractRawDataView[isotopeToRawIntensitiesMap.size()];
    rawDataSessionOverlayPlots = new AbstractRawDataView[isotopeToRawIntensitiesMap.size()];
    isotopeToRawIntensitiesMap.forEach((isotope, dataModel) -> {
        int index = massSpec.getVirtualCollectorModelMapToFieldIndexes().get(dataModel);
        rawDataSessionPlots[index] = new RawDataSessionPlot(dataModel, new Rectangle(0, index * 110 + 25, SESSION_VIEW_WIDTH, 100), false);
        rawDataSessionSerialContainer.add(rawDataSessionPlots[index], JLayeredPane.DEFAULT_LAYER);
        rawDataSessionPlots[index].preparePanel(true, false);
        rawDataSessionPlots[index].repaint();

        //overlays
        rawDataSessionOverlayPlots[index] = new RawDataSessionPlot(dataModel, new Rectangle(0, index * 110 + 25, placeHolderPane.getWidth() - 25, 100), true);
        rawDataSessionOverlayContainer.add(rawDataSessionOverlayPlots[index], JLayeredPane.DEFAULT_LAYER);
        rawDataSessionOverlayPlots[index].preparePanel(true, false);
        rawDataSessionOverlayPlots[index].repaint();
    });

    rawDataSessionSerialContainer.refreshPanel(true, false);
    rawDataSessionOverlayContainer.refreshPanel(true, false);

}