mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
cleanup
This commit is contained in:
@@ -22,19 +22,20 @@ public final class Util {
|
||||
private static final Dimension MAX_SIZE = new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE);
|
||||
public static final int DEFAULT_INDENT = 10;
|
||||
|
||||
public static Dimension getMinimumSize(final Component component, final GridConstraints constraints, final boolean addIndent){
|
||||
public static Dimension getMinimumSize(final Component component, final GridConstraints constraints, final boolean addIndent) {
|
||||
try {
|
||||
final Dimension size = getSize(constraints.myMinimumSize, component.getMinimumSize());
|
||||
if (addIndent) {
|
||||
size.width += DEFAULT_INDENT * constraints.getIndent();
|
||||
}
|
||||
return size;
|
||||
} catch (NullPointerException npe) { //IDEA-80722
|
||||
return new Dimension(0,0);
|
||||
}
|
||||
catch (NullPointerException npe) { //IDEA-80722
|
||||
return new Dimension(0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
public static Dimension getMaximumSize(final Component component, final GridConstraints constraints, final boolean addIndent){
|
||||
public static Dimension getMaximumSize(final GridConstraints constraints, final boolean addIndent) {
|
||||
try {
|
||||
//[anton] we use only our property for maximum size.
|
||||
// JButton reports that its max size = pref size, so it is impossible to make a column of same sized buttons.
|
||||
@@ -46,7 +47,7 @@ public final class Util {
|
||||
return size;
|
||||
}
|
||||
catch (NullPointerException e) {//IDEA-80722
|
||||
return new Dimension(0,0);
|
||||
return new Dimension(0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,11 +60,11 @@ public final class Util {
|
||||
return size;
|
||||
}
|
||||
catch (NullPointerException e) {//IDEA-80722
|
||||
return new Dimension(0,0);
|
||||
return new Dimension(0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
private static Dimension getSize(final Dimension overridenSize, final Dimension ownSize){
|
||||
private static Dimension getSize(final Dimension overridenSize, final Dimension ownSize) {
|
||||
final int overridenWidth = overridenSize.width >= 0 ? overridenSize.width : ownSize.width;
|
||||
final int overridenHeight = overridenSize.height >= 0 ? overridenSize.height : ownSize.height;
|
||||
return new Dimension(overridenWidth, overridenHeight);
|
||||
@@ -71,7 +72,7 @@ public final class Util {
|
||||
|
||||
public static void adjustSize(final Component component, final GridConstraints constraints, final Dimension size) {
|
||||
final Dimension minimumSize = getMinimumSize(component, constraints, false);
|
||||
final Dimension maximumSize = getMaximumSize(component, constraints, false);
|
||||
final Dimension maximumSize = getMaximumSize(constraints, false);
|
||||
|
||||
size.width = Math.max(size.width, minimumSize.width);
|
||||
size.height = Math.max(size.height, minimumSize.height);
|
||||
@@ -81,25 +82,24 @@ public final class Util {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param elimitated output parameter; will be filled indices (Integers) of eliminated cells. May be null.
|
||||
* @param elimitated output parameter; will be filled indices (Integers) of eliminated cells. May be null.
|
||||
* @return
|
||||
*/
|
||||
*/
|
||||
public static int eliminate(final int[] cellIndices, final int[] spans, final ArrayList elimitated) {
|
||||
final int size = cellIndices.length;
|
||||
if (size != spans.length){
|
||||
if (size != spans.length) {
|
||||
throw new IllegalArgumentException("size mismatch: " + size + ", " + spans.length);
|
||||
}
|
||||
if (elimitated != null && elimitated.size() != 0) {
|
||||
throw new IllegalArgumentException("eliminated must be empty");
|
||||
}
|
||||
|
||||
|
||||
int cellCount = 0;
|
||||
for (int i = 0; i < size; i++) {
|
||||
cellCount = Math.max(cellCount, cellIndices[i] + spans[i]);
|
||||
}
|
||||
|
||||
outer: for (int cell=cellCount - 1; cell >= 0; cell--) {
|
||||
for (int cell = cellCount - 1; cell >= 0; cell--) {
|
||||
// check if we should eliminate cell
|
||||
|
||||
boolean starts = false;
|
||||
@@ -118,10 +118,10 @@ public final class Util {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (elimitated != null){
|
||||
if (elimitated != null) {
|
||||
elimitated.add(new Integer(cell));
|
||||
}
|
||||
|
||||
|
||||
// eliminate cell
|
||||
for (int i = 0; i < size; i++) {
|
||||
final boolean decreaseSpan = cellIndices[i] <= cell && cell < cellIndices[i] + spans[i];
|
||||
|
||||
Reference in New Issue
Block a user