Skip to content

Commit

Permalink
PIVOT-370 :: Add showEmptyBranchControls to TerraTreeViewSkin
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.apache.org/repos/asf/incubator/pivot/trunk@893329 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
Todd Volkert committed Dec 22, 2009
1 parent 09ece0c commit 70c4874
Showing 1 changed file with 52 additions and 32 deletions.
Expand Up @@ -435,6 +435,7 @@ public void setExpanded(boolean expanded) {
private int indent;
private boolean showHighlight;
private boolean showBranchControls;
private boolean showEmptyBranchControls;
private Color branchControlColor;
private Color branchControlSelectionColor;
private Color branchControlInactiveSelectionColor;
Expand Down Expand Up @@ -470,6 +471,7 @@ public TerraTreeViewSkin() {
indent = 16;
showHighlight = true;
showBranchControls = true;
showEmptyBranchControls = true;
branchControlColor = theme.getColor(18);
branchControlSelectionColor = theme.getColor(4);
branchControlInactiveSelectionColor = theme.getColor(19);
Expand Down Expand Up @@ -643,48 +645,57 @@ public void paint(Graphics2D graphics) {
if (showBranchControls) {
if (nodeInfo instanceof BranchInfo) {
BranchInfo branchInfo = (BranchInfo)nodeInfo;
expanded = branchInfo.isExpanded();

Color branchControlColor;
boolean showBranchControl = true;
if (!showEmptyBranchControls) {
branchInfo.loadChildren();
showBranchControl = !branchInfo.children.isEmpty();
}

if (showBranchControl) {
expanded = branchInfo.isExpanded();

if (selected) {
if (treeView.isFocused()) {
branchControlColor = branchControlSelectionColor;
Color branchControlColor;

if (selected) {
if (treeView.isFocused()) {
branchControlColor = branchControlSelectionColor;
} else {
branchControlColor = branchControlInactiveSelectionColor;
}
} else {
branchControlColor = branchControlInactiveSelectionColor;
branchControlColor = this.branchControlColor;
}
} else {
branchControlColor = this.branchControlColor;
}

GeneralPath shape = new GeneralPath();
GeneralPath shape = new GeneralPath();

int imageX = nodeX + (indent - BRANCH_CONTROL_IMAGE_WIDTH) / 2;
int imageY = nodeY + (nodeHeight - BRANCH_CONTROL_IMAGE_HEIGHT) / 2;
int imageX = nodeX + (indent - BRANCH_CONTROL_IMAGE_WIDTH) / 2;
int imageY = nodeY + (nodeHeight - BRANCH_CONTROL_IMAGE_HEIGHT) / 2;

if (expanded) {
shape.moveTo(imageX, imageY + 1);
shape.lineTo(imageX + 8, imageY + 1);
shape.lineTo(imageX + 4, imageY + 7);
} else {
shape.moveTo(imageX + 1, imageY);
shape.lineTo(imageX + 7, imageY + 4);
shape.lineTo(imageX + 1, imageY + 8);
}
if (expanded) {
shape.moveTo(imageX, imageY + 1);
shape.lineTo(imageX + 8, imageY + 1);
shape.lineTo(imageX + 4, imageY + 7);
} else {
shape.moveTo(imageX + 1, imageY);
shape.lineTo(imageX + 7, imageY + 4);
shape.lineTo(imageX + 1, imageY + 8);
}

shape.closePath();
shape.closePath();

Graphics2D branchControlGraphics = (Graphics2D)graphics.create();
branchControlGraphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
if (!treeView.isEnabled()
|| disabled) {
branchControlGraphics.setComposite
(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.5f));
Graphics2D branchControlGraphics = (Graphics2D)graphics.create();
branchControlGraphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
if (!treeView.isEnabled()
|| disabled) {
branchControlGraphics.setComposite
(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.5f));
}
branchControlGraphics.setPaint(branchControlColor);
branchControlGraphics.fill(shape);
branchControlGraphics.dispose();
}
branchControlGraphics.setPaint(branchControlColor);
branchControlGraphics.fill(shape);
branchControlGraphics.dispose();
}

nodeX += indent + spacing;
Expand Down Expand Up @@ -1066,6 +1077,15 @@ public void setShowBranchControls(boolean showBranchControls) {
invalidateComponent();
}

public boolean getShowEmptyBranchControls() {
return showEmptyBranchControls;
}

public void setShowEmptyBranchControls(boolean showEmptyBranchControls) {
this.showEmptyBranchControls = showEmptyBranchControls;
repaintComponent();
}

public Color getBranchControlColor() {
return branchControlColor;
}
Expand Down

0 comments on commit 70c4874

Please sign in to comment.