本文整理匯總了Java中javax.swing.plaf.basic.BasicTreeUI.getExpandedIcon方法的典型用法代碼示例。如果您正苦於以下問題:Java BasicTreeUI.getExpandedIcon方法的具體用法?Java BasicTreeUI.getExpandedIcon怎麽用?Java BasicTreeUI.getExpandedIcon使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.swing.plaf.basic.BasicTreeUI
的用法示例。
在下文中一共展示了BasicTreeUI.getExpandedIcon方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: isLocationInExpandControl
import javax.swing.plaf.basic.BasicTreeUI; //導入方法依賴的package包/類
private boolean isLocationInExpandControl( TreePath path, Point location ) {
if( tree.getModel().isLeaf( path.getLastPathComponent() ) )
return false;
Rectangle r = tree.getPathBounds(path);
int boxWidth = 8;
Insets i = tree.getInsets();
int indent = 0;
if( tree.getUI() instanceof BasicTreeUI ) {
BasicTreeUI ui = (BasicTreeUI)tree.getUI();
if( null != ui.getExpandedIcon() )
boxWidth = ui.getExpandedIcon().getIconWidth();
indent = ui.getLeftChildIndent();
}
int boxX;
if( tree.getComponentOrientation().isLeftToRight() ) {
boxX = r.x - positionX - indent - boxWidth;
} else {
boxX = r.x - positionX + indent + r.width;
}
return location.getX() >= boxX && location.getX() <= (boxX + boxWidth);
}
示例2: isLocationInExpandControl
import javax.swing.plaf.basic.BasicTreeUI; //導入方法依賴的package包/類
protected boolean isLocationInExpandControl(@Nullable TreePath path, int mouseX) {
if (path == null) return false;
TreeUI ui = getUI();
if (!(ui instanceof BasicTreeUI)) return false;
BasicTreeUI treeUI = (BasicTreeUI)ui;
if (!treeModel.isLeaf(path.getLastPathComponent())) {
Insets insets = this.getInsets();
int boxWidth = treeUI.getExpandedIcon() != null ? treeUI.getExpandedIcon().getIconWidth() : 8;
int boxLeftX = treeUI.getLeftChildIndent() + treeUI.getRightChildIndent() * (path.getPathCount() - 1);
if (getComponentOrientation().isLeftToRight()) {
boxLeftX = boxLeftX + insets.left - treeUI.getRightChildIndent() + 1;
}
else {
boxLeftX = getWidth() - boxLeftX - insets.right + treeUI.getRightChildIndent() - 1;
}
boxLeftX -= getComponentOrientation().isLeftToRight() ? (int)Math.ceil(boxWidth / 2.0) : (int)Math.floor(boxWidth / 2.0);
return mouseX >= boxLeftX && mouseX < boxLeftX + boxWidth;
}
return false;
}
示例3: isLocationInExpandControl
import javax.swing.plaf.basic.BasicTreeUI; //導入方法依賴的package包/類
protected boolean isLocationInExpandControl(@Nullable TreePath path, int mouseX) {
if (path == null) return false;
TreeUI ui = getUI();
if (!(ui instanceof BasicTreeUI)) return false;
BasicTreeUI treeUI = (BasicTreeUI)ui;
if (!treeModel.isLeaf(path.getLastPathComponent())) {
Insets insets = Tree.this.getInsets();
int boxWidth = treeUI.getExpandedIcon() != null ? treeUI.getExpandedIcon().getIconWidth() : 8;
int boxLeftX = treeUI.getLeftChildIndent() + treeUI.getRightChildIndent() * (path.getPathCount() - 1);
if (getComponentOrientation().isLeftToRight()) {
boxLeftX = boxLeftX + insets.left - treeUI.getRightChildIndent() + 1;
}
else {
boxLeftX = getWidth() - boxLeftX - insets.right + treeUI.getRightChildIndent() - 1;
}
boxLeftX -= (getComponentOrientation().isLeftToRight() ? (int)Math.ceil(boxWidth / 2.0) : (int)Math.floor(boxWidth / 2.0));
return (mouseX >= boxLeftX && mouseX < (boxLeftX + boxWidth));
}
return false;
}
示例4: getBoxWidth
import javax.swing.plaf.basic.BasicTreeUI; //導入方法依賴的package包/類
private static int getBoxWidth(JTree tree) {
BasicTreeUI basicTreeUI = (BasicTreeUI)tree.getUI();
int boxWidth;
if (basicTreeUI.getExpandedIcon() != null) {
boxWidth = basicTreeUI.getExpandedIcon().getIconWidth();
}
else {
boxWidth = 8;
}
return boxWidth;
}
示例5: getExpandControlRange
import javax.swing.plaf.basic.BasicTreeUI; //導入方法依賴的package包/類
@Nullable
public static Range<Integer> getExpandControlRange(@NotNull final JTree aTree, @Nullable final TreePath path) {
TreeModel treeModel = aTree.getModel();
final BasicTreeUI basicTreeUI = (BasicTreeUI)aTree.getUI();
Icon expandedIcon = basicTreeUI.getExpandedIcon();
Range<Integer> box = null;
if (path != null && !treeModel.isLeaf(path.getLastPathComponent())) {
int boxWidth;
Insets i = aTree.getInsets();
if (expandedIcon != null) {
boxWidth = expandedIcon.getIconWidth();
}
else {
boxWidth = 8;
}
int boxLeftX = i != null ? i.left : 0;
boolean leftToRight = aTree.getComponentOrientation().isLeftToRight();
int depthOffset = getDepthOffset(aTree);
int totalChildIndent = basicTreeUI.getLeftChildIndent() + basicTreeUI.getRightChildIndent();
if (leftToRight) {
boxLeftX += (path.getPathCount() + depthOffset - 2) * totalChildIndent + basicTreeUI.getLeftChildIndent() -
boxWidth / 2;
}
int boxRightX = boxLeftX + boxWidth;
box = new Range<Integer>(boxLeftX, boxRightX);
}
return box;
}
示例6: getExpandControlRange
import javax.swing.plaf.basic.BasicTreeUI; //導入方法依賴的package包/類
@Nullable
public static Range<Integer> getExpandControlRange(@Nonnull final JTree aTree, @Nullable final TreePath path) {
TreeModel treeModel = aTree.getModel();
final BasicTreeUI basicTreeUI = (BasicTreeUI)aTree.getUI();
Icon expandedIcon = basicTreeUI.getExpandedIcon();
Range<Integer> box = null;
if (path != null && !treeModel.isLeaf(path.getLastPathComponent())) {
int boxWidth;
Insets i = aTree.getInsets();
if (expandedIcon != null) {
boxWidth = expandedIcon.getIconWidth();
}
else {
boxWidth = 8;
}
int boxLeftX = i != null ? i.left : 0;
boolean leftToRight = aTree.getComponentOrientation().isLeftToRight();
int depthOffset = getDepthOffset(aTree);
int totalChildIndent = basicTreeUI.getLeftChildIndent() + basicTreeUI.getRightChildIndent();
if (leftToRight) {
boxLeftX += (path.getPathCount() + depthOffset - 2) * totalChildIndent + basicTreeUI.getLeftChildIndent() -
boxWidth / 2;
}
int boxRightX = boxLeftX + boxWidth;
box = new Range<>(boxLeftX, boxRightX);
}
return box;
}