java swing rectangle_Java SwingUtilities.convertRectangle方法代碼示例

本文整理匯總了Java中javax.swing.SwingUtilities.convertRectangle方法的典型用法代碼示例。如果您正苦於以下問題:Java SwingUtilities.convertRectangle方法的具體用法?Java SwingUtilities.convertRectangle怎麽用?Java SwingUtilities.convertRectangle使用的例子?那麽恭喜您, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.swing.SwingUtilities的用法示例。

在下文中一共展示了SwingUtilities.convertRectangle方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於我們的係統推薦出更棒的Java代碼示例。

示例1: getDropIndication

​點讚 3

import javax.swing.SwingUtilities; //導入方法依賴的package包/類

@Override

protected Shape getDropIndication( TopComponent draggedTC, Point location ) {

location = SwingUtilities.convertPoint( getComponent(), location, getTabDisplayer() );

Path2D res = new Path2D.Double();

Rectangle tabRect = getTabDisplayer().dropIndication( draggedTC, location );

if( null != tabRect ) {

tabRect = SwingUtilities.convertRectangle( getTabDisplayer(), tabRect, container );

res.append( tabRect, false );

}

res.append( container.getContentArea(), false );

return res;

}

開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:13,

示例2: dropIndexOfPoint

​點讚 3

import javax.swing.SwingUtilities; //導入方法依賴的package包/類

@Override

public int dropIndexOfPoint( Point location ) {

int res = -1;

location = SwingUtilities.convertPoint( this, location, table );

TabData tab = table.getTabAt( location );

if( null != tab ) {

res = getModel().indexOf( tab );

Rectangle rect = getTabBounds( res );

rect = SwingUtilities.convertRectangle( this, rect, table );

if( orientation == JTabbedPane.VERTICAL ) {

if( location.y <= rect.y + rect.height/2 ) {

res = Math.max( 0, res );

} else {

res++;

}

} else {

if( location.x <= rect.x + rect.width/2 ) {

res = Math.max( 0, res );

} else {

res++;

}

}

}

return res;

}

開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:26,

示例3: getImageBounds

​點讚 2

import javax.swing.SwingUtilities; //導入方法依賴的package包/類

private Rectangle getImageBounds() {

if (!changed) {

return rect;

}

Component c = tabDisplayer;

r2.setBounds (0, 0, c.getWidth(), c.getHeight());

Rectangle dispBounds = SwingUtilities.convertRectangle(c, r2,

this);

if (orientation == TabDisplayer.ORIENTATION_WEST) {

rect.x = dispBounds.x + dispBounds.width;

rect.y = dispBounds.y;

rect.width = Math.round (inc * d.width);

rect.height = dispBounds.height;

} else if (orientation == TabDisplayer.ORIENTATION_EAST) {

rect.width = Math.round (inc * d.width);

rect.height = dispBounds.height;

rect.x = dispBounds.x - rect.width;

rect.y = dispBounds.y;

} else if (orientation == TabDisplayer.ORIENTATION_SOUTH) {

rect.width = dispBounds.width;

rect.height = Math.round(inc * d.height);

rect.x = dispBounds.x;

rect.y = dispBounds.y - rect.height;

} else if (orientation == TabDisplayer.ORIENTATION_NORTH) {

rect.x = dispBounds.x;

rect.y = dispBounds.y + dispBounds.height;

rect.width = dispBounds.width;

rect.height = Math.round(inc * d.height);

}

changed = false;

return rect;

}

開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:35,

示例4: createTabImage

​點讚 2

import javax.swing.SwingUtilities; //導入方法依賴的package包/類

private BufferedImage createTabImage() {

GraphicsConfiguration config = GraphicsEnvironment.getLocalGraphicsEnvironment()

.getDefaultScreenDevice().getDefaultConfiguration();

//the tab rectangle must be painted by top-level window otherwise the transparent

//button icons will be messed up

Window parentWindow = SwingUtilities.getWindowAncestor(container.getComponent());

Rectangle rect = SwingUtilities.convertRectangle(container.getComponent(), tabRectangle, parentWindow);

BufferedImage res = config.createCompatibleImage(tabRectangle.width, tabRectangle.height);

Graphics2D g = res.createGraphics();

g.translate(-rect.x, -rect.y);

g.setClip(rect);

parentWindow.paint(g);

return res;

}

開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:16,

示例5: getTabBounds

​點讚 2

import javax.swing.SwingUtilities; //導入方法依賴的package包/類

@Override

public Rectangle getTabBounds( int tabIndex ) {

Rectangle res = getTabDisplayer().getTabBounds( tabIndex );

if( null != res )

res = SwingUtilities.convertRectangle( getTabDisplayer(), res, container );

return res;

}

開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:8,

示例6: getTabBounds

​點讚 2

import javax.swing.SwingUtilities; //導入方法依賴的package包/類

Rectangle getTabBounds( int tabIndex ) {

TabData tab = tabModel.getTab( tabIndex );

if( null == tab )

return null;

for( SingleRowTabTable table : rows ) {

if( table.hasTabIndex( tabIndex ) ) {

Rectangle rect = table.getTabBounds( tabIndex );

if( null != rect ) {

rect = SwingUtilities.convertRectangle( table, rect, container );

}

return rect;

}

}

return null;

}

開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:16,

示例7: getTabBounds

​點讚 2

import javax.swing.SwingUtilities; //導入方法依賴的package包/類

@Override

public Rectangle getTabBounds( int tabIndex ) {

Rectangle res = table.getTabBounds( tabIndex );

if( null != res )

res = SwingUtilities.convertRectangle( table, res, this );

return res;

}

開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:8,

示例8: paint

​點讚 2

import javax.swing.SwingUtilities; //導入方法依賴的package包/類

public void paint(Graphics g) {

super.paint(g);

if (hover != null) {

Rectangle b = SwingUtilities.convertRectangle(

hover.getParent(), hover.getBounds(), this);

g.setColor(Color.RED);

g.drawRect(b.x, b.y, b.width, b.height);

}

}

開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:11,

示例9: redraw

​點讚 2

import javax.swing.SwingUtilities; //導入方法依賴的package包/類

/**

* Updates the buffer (if one exists) and repaints the given cell state.

*/

public void redraw(mxCellState state)

{

if (state != null)

{

Rectangle dirty = state.getBoundingBox().getRectangle();

repaintTripleBuffer(new Rectangle(dirty));

dirty = SwingUtilities.convertRectangle(graphControl, dirty, this);

repaint(dirty);

}

}

開發者ID:GDSRS,項目名稱:TrabalhoFinalEDA2,代碼行數:14,

示例10: redraw

​點讚 2

import javax.swing.SwingUtilities; //導入方法依賴的package包/類

/**

* Updates the buffer (if one exists) and repaints the given cell state.

*/

public void redraw(mxCellState state) {

if (state != null) {

Rectangle dirty = state.getBoundingBox().getRectangle();

repaintTripleBuffer(new Rectangle(dirty));

dirty = SwingUtilities.convertRectangle(graphControl, dirty, this);

repaint(dirty);

}

}

開發者ID:ModelWriter,項目名稱:Tarski,代碼行數:12,

示例11: configureBalloon

​點讚 2

import javax.swing.SwingUtilities; //導入方法依賴的package包/類

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 );

}

}

開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:44,

示例12: updateOrientation

​點讚 2

import javax.swing.SwingUtilities; //導入方法依賴的package包/類

/** Checks the position of the tabbed container relative to its parent

* window, and potentially updates its orientation client property.

*

* @see TabDisplayer#PROP_ORIENTATION

*/

protected final void updateOrientation() {

if (!container.isDisplayable()) {

return;

}

if (Boolean.FALSE.equals(container.getClientProperty (TabbedContainer.PROP_MANAGE_TAB_POSITION))) {

//The client has specified that it does not want automatic management

//of the displayer orientation

return;

}

Object currOrientation = tabDisplayer.getClientProperty(TabDisplayer.PROP_ORIENTATION);

Container window = container.getTopLevelAncestor();

Rectangle containerBounds = container.getBounds();

containerBounds = SwingUtilities.convertRectangle(container, containerBounds, window);

boolean longestIsVertical = containerBounds.width < containerBounds.height;

int distanceToLeft = containerBounds.x;

int distanceToTop = containerBounds.y;

int distanceToRight = window.getWidth() - (containerBounds.x + containerBounds.width);

int distanceToBottom = window.getHeight() - (containerBounds.y + containerBounds.height);

Object orientation;

if (!longestIsVertical) {

if (distanceToBottom > distanceToTop) {

orientation = TabDisplayer.ORIENTATION_NORTH;

} else {

orientation = TabDisplayer.ORIENTATION_SOUTH;

}

} else {

if (distanceToLeft > distanceToRight) {

orientation = TabDisplayer.ORIENTATION_EAST;

} else {

orientation = TabDisplayer.ORIENTATION_WEST;

}

}

if (currOrientation != orientation) {

tabDisplayer.putClientProperty(

TabDisplayer.PROP_ORIENTATION, orientation);

container.validate();

}

}

開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:49,

示例13: getTabsArea

​點讚 2

import javax.swing.SwingUtilities; //導入方法依賴的package包/類

@Override

public Rectangle getTabsArea() {

Rectangle res = container.getTabDisplayer().getTabsArea();

res = SwingUtilities.convertRectangle( getTabDisplayer(), res, container );

return res;

}

開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:7,

示例14: toComponentPane

​點讚 1

import javax.swing.SwingUtilities; //導入方法依賴的package包/類

/**

* Converts a {@code rectangle} in {@code innerPane} coordinates to

* a corresponding rectangle in {@code componentPane} coordinates.

*

* @param rectangle rectangle in {@code innerPane} coordinates.

* @return rectangle in {@code componentPane} coordinates.

*/

Rectangle toComponentPane(Rectangle rectangle) {

return SwingUtilities.convertRectangle(innerPane, rectangle, componentPane);

}

開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:11,

示例15: fromComponentPane

​點讚 1

import javax.swing.SwingUtilities; //導入方法依賴的package包/類

/**

* Converts a {@code rectangle} in {@code componentPane} coordinates to

* a corresponding rectangle in {@code innerPane} coordinates.

*

* @param rectangle rectangle in {@code componentPane} coordinates.

* @return rectangle in {@code innerPane} coordinates.

*/

Rectangle fromComponentPane(Rectangle rectangle) {

return SwingUtilities.convertRectangle(componentPane, rectangle, innerPane);

}

開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:11,

注:本文中的javax.swing.SwingUtilities.convertRectangle方法示例整理自Github/MSDocs等源碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值