Skip to content
Commits on Source (12)
......@@ -29,3 +29,13 @@
/javafx/.settings
/javafx/target
/javafx/.classpath
#
# ignore target folders in the build tree
#
**/target
#
# ignore eclipse local settings files
#
**/.project
**/.classpath
**/.settings
# miglayout
Official MiG Layout for Swing, SWT and JavaFX
For Java developers writing GUI layouts by hand that wants simplicity, power and automatic per platform fidelity, that are dissatisfied with the current layout managers in Swing, JavaFX and SWT, MigLayout solves your layout problems. User interfaces created with MigLayout is easy to maintain, you will understand how the layout will look like just by looking at the source code.
MigLayout is a superbly versatile JavaFX/SWT/Swing layout manager that makes layout problems trivial. It is using String or API type-checked constraints to format the layout. MigLayout can produce flowing, grid based, absolute (with links), grouped and docking layouts. You will never have to switch to another layout manager ever again! MigLayout is created to be to manually coded layouts what Matisse/GroupLayout is to IDE supported visual layouts.
......@@ -4,7 +4,7 @@
<parent>
<groupId>com.miglayout</groupId>
<artifactId>miglayout-parent</artifactId>
<version>4.2</version>
<version>5.1-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>miglayout-core</artifactId>
......
......@@ -44,11 +44,11 @@ import java.util.ArrayList;
* For a more thorough explanation of what these constraints do, and how to build the constraints, see the White Paper or Cheat Sheet at www.migcomponents.com.
* <p>
* Note that there are two way to build this constraint. Through String (e.g. <code>"[100]3[200,fill]"</code> or through API (E.g.
* <code>new AxisConstraint().size("100").gap("3").size("200").fill()</code>.
* <code>new AC().size("100").gap("3").size("200").fill()</code>.
*/
public final class AC implements Externalizable
{
private final ArrayList<DimConstraint> cList = new ArrayList<DimConstraint>(8);
private final ArrayList<DimConstraint> cList = new ArrayList<DimConstraint>(1);
private transient int curIx = 0;
......@@ -61,7 +61,7 @@ public final class AC implements Externalizable
}
/** Property. The different {@link net.miginfocom.layout.DimConstraint}s that this object consists of.
* These <code><DimConstraints/code> contains all information in this class.
* These <code>DimConstraints</code> contains all information in this class.
* <p>
* Yes, we are embarrassingly aware that the method is misspelled.
* @return The different {@link net.miginfocom.layout.DimConstraint}s that this object consists of. A new list and
......@@ -76,7 +76,7 @@ public final class AC implements Externalizable
* <p>
* Yes, we are embarrassingly aware that the method is misspelled.
* @param constr The different {@link net.miginfocom.layout.DimConstraint}s that this object consists of. The list
* will be copied for storage. <code>null</code> or and emty array will reset the constraints to one <code>DimConstraint</code>
* will be copied for storage. <code>null</code> or and empty array will reset the constraints to one <code>DimConstraint</code>
* with default values.
*/
public final void setConstaints(DimConstraint[] constr)
......@@ -109,7 +109,7 @@ public final class AC implements Externalizable
return this;
}
/** Specifies that the current row/column should not be grid-like. The while row/colum will have its components layed out
/** Specifies that the current row/column should not be grid-like. The while row/column will have its components layed out
* in one single cell. It is the same as to say that the cells in this column/row will all be merged (a.k.a spanned).
* <p>
* For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
......@@ -120,7 +120,7 @@ public final class AC implements Externalizable
return noGrid(curIx);
}
/** Specifies that the indicated rows/columns should not be grid-like. The while row/colum will have its components layed out
/** Specifies that the indicated rows/columns should not be grid-like. The while row/column will have its components layed out
* in one single cell. It is the same as to say that the cells in this column/row will all be merged (a.k.a spanned).
* <p>
* For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
......@@ -294,6 +294,7 @@ public final class AC implements Externalizable
public final AC gap()
{
curIx++;
makeSize(curIx);
return this;
}
......@@ -323,7 +324,7 @@ public final class AC implements Externalizable
for (int i = indexes.length - 1; i >= 0; i--) {
int ix = indexes[i];
makeSize(ix);
makeSize(ix + 1);
if (bsa != null)
cList.get(ix).setGapAfter(bsa);
}
......@@ -331,7 +332,7 @@ public final class AC implements Externalizable
}
/** Specifies the current row/column's columns default alignment <b>for its components</b>. It does not affect the positioning
* or size of the columns/row itself. For columns it is the horizonal alignment (e.g. "left") and for rows it is the vertical
* or size of the columns/row itself. For columns it is the horizontal alignment (e.g. "left") and for rows it is the vertical
* alignment (e.g. "top").
* <p>
* For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
......@@ -344,7 +345,7 @@ public final class AC implements Externalizable
}
/** Specifies the indicated rows'/columns' columns default alignment <b>for its components</b>. It does not affect the positioning
* or size of the columns/row itself. For columns it is the horizonal alignment (e.g. "left") and for rows it is the vertical
* or size of the columns/row itself. For columns it is the horizontal alignment (e.g. "left") and for rows it is the vertical
* alignment (e.g. "top").
* <p>
* For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
......@@ -404,7 +405,7 @@ public final class AC implements Externalizable
*/
public final AC grow()
{
return grow(1f, curIx);
return grow(100f, curIx);
}
/** Specifies the current row/column's grow weight within columns/rows with the same <code>grow priority</code>.
......@@ -464,7 +465,7 @@ public final class AC implements Externalizable
return this;
}
/** Specifies that the current row/column's shrink weight withing the columns/rows with the <code>shrink priority</code> 100f.
/** Specifies that the current row/column's shrink weight within the columns/rows with the <code>shrink priority</code> 100f.
* <p>
* Same as <code>shrink(100f)</code>.
* <p>
......@@ -477,7 +478,7 @@ public final class AC implements Externalizable
return shrink(100f, curIx);
}
/** Specifies that the current row/column's shrink weight withing the columns/rows with the same <code>shrink priority</code>.
/** Specifies that the current row/column's shrink weight within the columns/rows with the same <code>shrink priority</code>.
* <p>
* For a more thorough explanation of what this constraint does see the White Paper or Cheat Sheet at www.migcomponents.com.
* @param w The shrink weight.
......@@ -489,7 +490,7 @@ public final class AC implements Externalizable
return shrink(w, curIx);
}
/** Specifies the indicated rows'/columns' shrink weight withing the columns/rows with the same <code>shrink priority</code>.
/** Specifies the indicated rows'/columns' shrink weight within the columns/rows with the same <code>shrink priority</code>.
* <p>
* For a more thorough explanation of what this constraint does see the White Paper or Cheat Sheet at www.migcomponents.com.
* @param w The shrink weight.
......@@ -508,7 +509,7 @@ public final class AC implements Externalizable
return this;
}
/** Specifies that the current row/column's shrink weight withing the columns/rows with the same <code>shrink priority</code>.
/** Specifies that the current row/column's shrink weight within the columns/rows with the same <code>shrink priority</code>.
* <p>
* For a more thorough explanation of what this constraint does see the White Paper or Cheat Sheet at www.migcomponents.com.
* @param w The shrink weight.
......@@ -520,7 +521,7 @@ public final class AC implements Externalizable
return shrink(w);
}
/** Specifies the indicated rows'/columns' shrink weight withing the columns/rows with the same <code>shrink priority</code>.
/** Specifies the indicated rows'/columns' shrink weight within the columns/rows with the same <code>shrink priority</code>.
* <p>
* For a more thorough explanation of what this constraint does see the White Paper or Cheat Sheet at www.migcomponents.com.
* @param w The shrink weight.
......@@ -551,11 +552,13 @@ public final class AC implements Externalizable
return LayoutUtil.getSerializedObject(this);
}
@Override
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
{
LayoutUtil.setSerializedObject(this, LayoutUtil.readAsXML(in));
}
@Override
public void writeExternal(ObjectOutput out) throws IOException
{
if (getClass() == AC.class)
......
package net.miginfocom.layout;
/*
* License (BSD):
* ==============
*
* Copyright (c) 2004, Mikael Grev, MiG InfoCom AB. (miglayout (at) miginfocom (dot) com)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this list
* of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this
* list of conditions and the following disclaimer in the documentation and/or other
* materials provided with the distribution.
* Neither the name of the MiG InfoCom AB nor the names of its contributors may be
* used to endorse or promote products derived from this software without specific
* prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
* OF SUCH DAMAGE.
*
* @version 1.0
*/
import java.io.Serializable;
/**
* @author Mikael Grev, MiG InfoCom AB
* Date: 14-09-24
* Time: 17:05
*/
public class AnimSpec implements Serializable
{
// public static final AnimSpec OFF = new AnimSpec(-1, 0, 0);
public static final AnimSpec DEF = new AnimSpec(0, 0, 0.2f, 0.2f);
private final int prio;
private final int durMillis;
private final float easeIn, easeOut;
/**
* @param prio The animation priority. When added with the general animation priority of the layout the animation will
* be done if the resulting value is &gt; 0.
* @param durMillis Duration in milliseconds. <=0 means default value should be used and > 0 is the number of millis
* @param easeIn 0 is linear (no ease). 1 is max ease. Always clamped between these values.
* @param easeOut 0 is linear (no ease). 1 is max ease. Always clamped between these values.
*/
public AnimSpec(int prio, int durMillis, float easeIn, float easeOut)
{
this.prio = prio;
this.durMillis = durMillis;
this.easeIn = LayoutUtil.clamp(easeIn, 0, 1);
this.easeOut = LayoutUtil.clamp(easeOut, 0, 1);
}
/**
* @return The animation priority. When added with the general animation priority of the layout the animation will
* be done if the resulting value is &gt; 0.
*/
public int getPriority()
{
return prio;
}
/**
* @param defMillis Default used if the millis in the spec is set to "default".
* @return Duration in milliseconds. <=0 means default value should be used and > 0 is the number of millis
*/
public int getDurationMillis(int defMillis)
{
return durMillis > 0 ? durMillis : defMillis;
}
/**
* @return Duration in milliseconds. <= 0 means default value should be used and > 0 is the number of millis
*/
public int getDurationMillis()
{
return durMillis;
}
/**
* @return A value between 0 and 1 where 0 is no ease in and 1 is maximum ease in.
*/
public float getEaseIn()
{
return easeIn;
}
/**
* @return A value between 0 and 1 where 0 is no ease out and 1 is maximum ease out.
*/
public float getEaseOut()
{
return easeOut;
}
}
......@@ -65,7 +65,7 @@ public class BoundSize implements Serializable
this(minMaxPref, minMaxPref, minMaxPref, createString);
}
/** Constructor. <b>This method is here for serilization only and should normally not be used. Use
/** Constructor. <b>This method is here for serialization only and should normally not be used.</b> Use
* {@link ConstraintParser#parseBoundSize(String, boolean, boolean)} instead.
* @param min The minimum size. May be <code>null</code>.
* @param preferred The preferred size. May be <code>null</code>.
......@@ -77,7 +77,7 @@ public class BoundSize implements Serializable
this(min, preferred, max, false, createString);
}
/** Constructor. <b>This method is here for serilization only and should normally not be used. Use
/** Constructor. <b>This method is here for serialization only and should normally not be used.</b> Use
* {@link ConstraintParser#parseBoundSize(String, boolean, boolean)} instead.
* @param min The minimum size. May be <code>null</code>.
* @param preferred The preferred size. May be <code>null</code>.
......@@ -175,7 +175,7 @@ public class BoundSize implements Serializable
* @param refSize The reference size.
* @param parent The parent. Not <code>null</code>.
* @param comp The component, if applicable, can be <code>null</code>.
* @return An array of lenth three (min,pref,max).
* @return An array of length three (min,pref,max).
*/
final int[] getPixelSizes(float refSize, ContainerWrapper parent, ComponentWrapper comp)
{
......@@ -225,13 +225,29 @@ public class BoundSize implements Serializable
void checkNotLinked()
{
if (min != null && min.isLinkedDeep() || pref != null && pref.isLinkedDeep() || max != null && max.isLinkedDeep())
if (isLinked())
throw new IllegalArgumentException("Size may not contain links");
}
boolean isLinked()
{
return min != null && min.isLinkedDeep() || pref != null && pref.isLinkedDeep() || max != null && max.isLinkedDeep();
}
boolean isAbsolute()
{
return (min == null || min.isAbsoluteDeep()) && (pref == null || pref.isAbsoluteDeep()) && (max == null || max.isAbsoluteDeep());
}
public String toString()
{
return "BoundSize{" + "min=" + min + ", pref=" + pref + ", max=" + max + ", gapPush=" + gapPush +'}';
}
static {
if(LayoutUtil.HAS_BEANS){
LayoutUtil.setDelegate(BoundSize.class, new PersistenceDelegate() {
@Override
protected Expression instantiate(Object oldInstance, Encoder out)
{
BoundSize bs = (BoundSize) oldInstance;
......
......@@ -52,6 +52,8 @@ public final class CC implements Externalizable
private UnitValue[] padding = null; // top, left, bottom, right
private UnitValue[] visualPadding = null; // top, left, bottom, right
private Boolean flowX = null;
private int skip = 0;
......@@ -82,6 +84,8 @@ public final class CC implements Externalizable
private Float pushX = null, pushY = null;
private AnimSpec animSpec = AnimSpec.DEF;
// ***** Tmp cache field
......@@ -527,6 +531,19 @@ public final class CC implements Externalizable
* @param w The new grow weight.
* @return <code>this</code> so it is possible to chain calls. E.g. <code>new ComponentConstraint().noGrid().gap().fill()</code>.
*/
public final CC growY(float w)
{
ver.setGrow(w);
return this;
}
/** Grow weight for the component vertically.
* <p>
* For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
* @param w The new grow weight.
* @return <code>this</code> so it is possible to chain calls. E.g. <code>new ComponentConstraint().noGrid().gap().fill()</code>.
*/
@Deprecated
public final CC growY(Float w)
{
ver.setGrow(w);
......@@ -604,7 +621,7 @@ public final class CC implements Externalizable
* returns <code>this</code> for chaining multiple calls.
* <p>
* For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
* @param colRowWidthHeight cellX, cellY, spanX, spanY repectively. 1-4 arguments, not null.
* @param colRowWidthHeight cellX, cellY, spanX, spanY respectively. 1-4 arguments, not null.
* @return <code>this</code> so it is possible to chain calls. E.g. <code>new LayoutConstraint().noGrid().gap().fill()</code>.
* @see #setCellX(int)
* @see #setCellY(int)
......@@ -694,7 +711,7 @@ public final class CC implements Externalizable
/** Sets the horizontal gap after the component.
* <p>
* Note! This is currently same as gapLeft(). This might change in 4.x.
* Note! This is currently same as gapRight(). This might change in 4.x.
* @param boundsSize The size of the gap expressed as a <code>BoundSize</code>. E.g. "50:100px:200mm" or "100px!".
* @return <code>this</code> so it is possible to chain calls. E.g. <code>new LayoutConstraint().noGrid().gap().fill()</code>.
* @since 3.7.2
......@@ -749,7 +766,7 @@ public final class CC implements Externalizable
return this;
}
/** Same functionality as {@link #setSpanY(int LayoutUtil.INF)} which means this cell will span the rest of the column.
/** Same functionality as calling {@link #setSpanY(int)} with <code>LayoutUtil.INF</code> which means this cell will span the rest of the column.
* This method returns <code>this</code> for chaining multiple calls.
* <p>
* For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
......@@ -833,7 +850,7 @@ public final class CC implements Externalizable
return pushX(weightX).pushY(weightY);
}
/** Same functionality as {@link #setPushY(Float))} which means this cell will push the rest of the column.
/** Same functionality as {@link #setPushY(Float)} which means this cell will push the rest of the column.
* This method returns <code>this</code> for chaining multiple calls.
* <p>
* For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
......@@ -936,7 +953,7 @@ public final class CC implements Externalizable
return this;
}
/** Same functionality as {@link #setExternal(boolean true)} only this method returns <code>this</code> for chaining multiple calls.
/** Same functionality as calling {@link #setExternal(boolean)} with <code>true</code> only this method returns <code>this</code> for chaining multiple calls.
* <p>
* For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
* @return <code>this</code> so it is possible to chain calls. E.g. <code>new ComponentConstraint().noGrid().gap().fill()</code>.
......@@ -948,7 +965,7 @@ public final class CC implements Externalizable
return this;
}
/** Same functionality as {@link #setFlowX(Boolean .TRUE)} only this method returns <code>this</code> for chaining multiple calls.
/** Same functionality as calling {@link #setFlowX(Boolean)} with <code>Boolean.TRUE</code> only this method returns <code>this</code> for chaining multiple calls.
* <p>
* For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
* @return <code>this</code> so it is possible to chain calls. E.g. <code>new ComponentConstraint().noGrid().gap().fill()</code>.
......@@ -960,7 +977,7 @@ public final class CC implements Externalizable
return this;
}
/** Same functionality as {@link #setFlowX(Boolean .FALSE)} only this method returns <code>this</code> for chaining multiple calls.
/** Same functionality as calling {@link #setFlowX(Boolean)} with <code>Boolean.FALSE</code> only this method returns <code>this</code> for chaining multiple calls.
* <p>
* For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
* @return <code>this</code> so it is possible to chain calls. E.g. <code>new ComponentConstraint().noGrid().gap().fill()</code>.
......@@ -987,7 +1004,7 @@ public final class CC implements Externalizable
return this;
}
/** Same functionality as {@link #setNewline(boolean true)} only this method returns <code>this</code> for chaining multiple calls.
/** Same functionality as calling {@link #setNewline(boolean)} with <code>true</code> only this method returns <code>this</code> for chaining multiple calls.
* <p>
* For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
* @return <code>this</code> so it is possible to chain calls. E.g. <code>new ComponentConstraint().noGrid().gap().fill()</code>.
......@@ -1002,7 +1019,7 @@ public final class CC implements Externalizable
/** Same functionality as {@link #setNewlineGapSize(BoundSize)} only this method returns <code>this</code> for chaining multiple calls.
* <p>
* For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
* @param gapSize The gap size that will override the gap size in the row/colum constraints if <code>!= null</code>. E.g. "5px" or "unrel".
* @param gapSize The gap size that will override the gap size in the row/column constraints if <code>!= null</code>. E.g. "5px" or "unrel".
* If <code>null</code> or <code>""</code> the newline size will be set to the default size and turned on. This is different compared to
* {@link #setNewlineGapSize(BoundSize)}.
* @return <code>this</code> so it is possible to chain calls. E.g. <code>new ComponentConstraint().noGrid().gap().fill()</code>.
......@@ -1019,7 +1036,7 @@ public final class CC implements Externalizable
return this;
}
/** Same functionality as {@link #setWrap(boolean true)} only this method returns <code>this</code> for chaining multiple calls.
/** Same functionality as calling {@link #setWrap(boolean)} with <code>true</code> only this method returns <code>this</code> for chaining multiple calls.
* <p>
* For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
* @return <code>this</code> so it is possible to chain calls. E.g. <code>new ComponentConstraint().noGrid().gap().fill()</code>.
......@@ -1034,7 +1051,7 @@ public final class CC implements Externalizable
/** Same functionality as {@link #setWrapGapSize(BoundSize)} only this method returns <code>this</code> for chaining multiple calls.
* <p>
* For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
* @param gapSize The gap size that will override the gap size in the row/colum constraints if <code>!= null</code>. E.g. "5px" or "unrel".
* @param gapSize The gap size that will override the gap size in the row/column constraints if <code>!= null</code>. E.g. "5px" or "unrel".
* If <code>null</code> or <code>""</code> the wrap size will be set to the default size and turned on. This is different compared to
* {@link #setWrapGapSize(BoundSize)}.
* @return <code>this</code> so it is possible to chain calls. E.g. <code>new ComponentConstraint().noGrid().gap().fill()</code>.
......@@ -1051,7 +1068,7 @@ public final class CC implements Externalizable
return this;
}
/** Same functionality as {@link #setDockSide(int 0)} only this method returns <code>this</code> for chaining multiple calls.
/** Same functionality as calling {@link #setDockSide(int)} with <code>0</code> only this method returns <code>this</code> for chaining multiple calls.
* <p>
* For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
* @return <code>this</code> so it is possible to chain calls. E.g. <code>new ComponentConstraint().noGrid().gap().fill()</code>.
......@@ -1063,7 +1080,7 @@ public final class CC implements Externalizable
return this;
}
/** Same functionality as {@link #setDockSide(int 1)} only this method returns <code>this</code> for chaining multiple calls.
/** Same functionality as calling {@link #setDockSide(int)} with <code>1</code> only this method returns <code>this</code> for chaining multiple calls.
* <p>
* For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
* @return <code>this</code> so it is possible to chain calls. E.g. <code>new ComponentConstraint().noGrid().gap().fill()</code>.
......@@ -1075,7 +1092,7 @@ public final class CC implements Externalizable
return this;
}
/** Same functionality as {@link #setDockSide(int 2)} only this method returns <code>this</code> for chaining multiple calls.
/** Same functionality as calling {@link #setDockSide(int)} with <code>2</code> only this method returns <code>this</code> for chaining multiple calls.
* <p>
* For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
* @return <code>this</code> so it is possible to chain calls. E.g. <code>new ComponentConstraint().noGrid().gap().fill()</code>.
......@@ -1087,7 +1104,7 @@ public final class CC implements Externalizable
return this;
}
/** Same functionality as {@link #setDockSide(int 3)} only this method returns <code>this</code> for chaining multiple calls.
/** Same functionality as calling {@link #setDockSide(int)} with <code>3</code> only this method returns <code>this</code> for chaining multiple calls.
* <p>
* For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
* @return <code>this</code> so it is possible to chain calls. E.g. <code>new ComponentConstraint().noGrid().gap().fill()</code>.
......@@ -1168,7 +1185,7 @@ public final class CC implements Externalizable
return this;
}
/** Same functionality as {@link #x(String x)} and {@link #y(String y)} toghether.
/** Same functionality as {@link #x(String x)} and {@link #y(String y)} together.
* <p>
* For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
* @param x The x position as a UnitValue. E.g. "10" or "40mm" or "container.x+10".
......@@ -1190,7 +1207,7 @@ public final class CC implements Externalizable
return this;
}
/** Same functionality as {@link #x(String x)}, {@link #y(String y)}, {@link #y2(String y)} and {@link #y2(String y)} toghether.
/** Same functionality as {@link #x(String x)}, {@link #y(String y)}, {@link #y2(String y)} and {@link #y2(String y)} together.
* <p>
* For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
* @param x The x position as a UnitValue. E.g. "10" or "40mm" or "container.x+10".
......@@ -1248,7 +1265,7 @@ public final class CC implements Externalizable
// **********************************************************
/** Returns the horizontal dimension constraint for this component constraint. It has constraints for the horizontal size
* and grow/shink priorities and weights.
* and grow/shrink priorities and weights.
* <p>
* Note! If any changes is to be made it must be made direct when the object is returned. It is not allowed to save the
* constraint for later use.
......@@ -1547,6 +1564,26 @@ public final class CC implements Externalizable
this.padding = sides != null ? new UnitValue[] {sides[0], sides[1], sides[2], sides[3]} : null;
}
/** Returns the visual padding used when laying out this Component. May be <code>null</code> and elements may be <code>null</code>.
* <p>
* For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
* @return The current value. <code>null</code> or of length 4.
*/
public UnitValue[] getVisualPadding()
{
return visualPadding != null ? new UnitValue[] {visualPadding[0], visualPadding[1], visualPadding[2], visualPadding[3]} : null;
}
/** Sets the visual padding used when laying out this Component.
* <p>
* For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
* @param sides top, left, bottom right. Must be <code>null</code> or of length 4.
*/
public void setVisualPadding(UnitValue[] sides)
{
this.visualPadding = sides != null ? new UnitValue[] {sides[0], sides[1], sides[2], sides[3]} : null;
}
/** Returns how many cells in the grid that should be skipped <b>before</b> the component that this constraint belongs to.
* <p>
* Note that only the first component will be checked for this property.
......@@ -1712,7 +1749,7 @@ public final class CC implements Externalizable
return tag;
}
/** Optinal tag that gives more context to this constraint's component. It is for instance used to tag buttons in a
/** Optional tag that gives more context to this constraint's component. It is for instance used to tag buttons in a
* button bar with the button type such as "ok", "help" or "cancel".
* <p>
* For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
......@@ -1811,6 +1848,15 @@ public final class CC implements Externalizable
newline = s == null ? (newline != null ? DEF_GAP : null) : s;
}
/** Returns the animation spec. Default is a spec where animation is off (prio 0).
* @return Never null.
*/
public AnimSpec getAnimSpec()
{
return animSpec;
}
// ************************************************
// Persistence Delegate and Serializable combined.
// ************************************************
......@@ -1820,11 +1866,13 @@ public final class CC implements Externalizable
return LayoutUtil.getSerializedObject(this);
}
@Override
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
{
LayoutUtil.setSerializedObject(this, LayoutUtil.readAsXML(in));
}
@Override
public void writeExternal(ObjectOutput out) throws IOException
{
if (getClass() == CC.class)
......
......@@ -35,7 +35,7 @@ package net.miginfocom.layout;
/** A class that wraps the important parts of a Component.
* <p>
* <b>NOTE!</b>.equals() and .hashcode() should be shunted to the wrapped component. E.g.
* <b>NOTE!</b>.equals() and .hashcode() should be forwarded to the wrapped component. E.g.
* <pre>
* public int hashCode()
{
......@@ -73,6 +73,7 @@ public interface ComponentWrapper
public static final int TYPE_CHECK_BOX = 16;
public static final int TYPE_SCROLL_BAR = 17;
public static final int TYPE_SEPARATOR = 18;
public static final int TYPE_TABBED_PANE = 19;
/** Returns the actual object that this wrapper is aggregating. This might be needed for getting
* information about the object that the wrapper interface does not provide.
......@@ -280,18 +281,25 @@ public interface ComponentWrapper
public int[] getVisualPadding();
/** Paints component outline to indicate where it is.
* @param showVisualPadding If the visual padding should be shown in the debug drawing.
*/
public abstract void paintDebugOutline();
public abstract void paintDebugOutline(boolean showVisualPadding);
/** Returns the type of component that this wrapper is wrapping.
* <p>
* This method can be invoked often so the result should be cached.
* <p>
* <b>NOTE!</b> This is misspelled. Keeping it that way though since this is only used by developers who
* port MigLayout.
* @param disregardScrollPane Is <code>true</code> any wrapping scroll pane should be disregarded and the type
* of the scrolled component should be returned.
* @return The type of component that this wrapper is wrapping. E.g. {@link #TYPE_LABEL}.
*/
public abstract int getComponetType(boolean disregardScrollPane);
public abstract int getComponentType(boolean disregardScrollPane);
/** Returns in what way the min/pref/max sizes relates to it's height or width for the current settings of the component (like wrapText).
* If the min/pref/max height depends on it's width return {@link net.miginfocom.layout.LayoutUtil#HORIZONTAL}
* If the min/pref/max width depends on it's height (not common) return {@link net.miginfocom.layout.LayoutUtil#VERTICAL}
* If there is no connection between the preferred min/pref/max and the size of the component return -1.
* @since 5.0
*/
public abstract int getContentBias();
}
\ No newline at end of file
......@@ -46,15 +46,15 @@ public final class ConstraintParser
{
}
/** Parses the layout constraints and stores the parsed values in the transient (cache) member varables.
/** Parses the layout constraints and stores the parsed values in the transient (cache) member variables.
* @param s The String to parse. Should not be <code>null</code> and <b>must be lower case and trimmed</b>.
* @throws RuntimeException if the constaint was not valid.
* @throws RuntimeException if the constraint was not valid.
* @return The parsed constraint. Never <code>null</code>.
*/
public static LC parseLayoutConstraint(String s)
{
LC lc = new LC();
if (s.length() == 0)
if (s.isEmpty())
return lc;
String[] parts = toTrimmedTokens(s, ',');
......@@ -226,8 +226,12 @@ public final class ConstraintParser
if (ix > -1) {
String[] gaps = toTrimmedTokens(part.substring(ix).trim(), ' ');
lc.setAlignX(parseUnitValueOrAlign(gaps[0], true, null));
if (gaps.length > 1)
lc.setAlignY(parseUnitValueOrAlign(gaps[1], false, null));
if (gaps.length > 1) {
UnitValue align = parseUnitValueOrAlign(gaps[1], false, null);
if (align == UnitValue.BASELINE_IDENTITY)
throw new IllegalArgumentException("'baseline' can not be used to align the whole component group.");
lc.setAlignY(align);
}
continue;
}
}
......@@ -428,13 +432,13 @@ public final class ConstraintParser
dimConstraint.setSize(parseBoundSize(part, false, isCols));
} catch (Exception ex) {
throw new IllegalArgumentException("Illegal contraint: '" + part + "'\n" + ex.getMessage());
throw new IllegalArgumentException("Illegal constraint: '" + part + "'\n" + ex.getMessage());
}
}
return dimConstraint;
}
/** Parses all component constraints and stores the parsed values in the transient (cache) member varables.
/** Parses all component constraints and stores the parsed values in the transient (cache) member variables.
* @param constrMap The constraints as <code>String</code>s. Strings <b>must be lower case and trimmed</b>
* @return The parsed constraints. Never <code>null</code>.
*/
......@@ -451,15 +455,15 @@ public final class ConstraintParser
}
/** Parses one component constraint and returns the parsed value.
* @param s The string to parse. Should not be <code>null</code> and <b>must be lower case and trimmed</b>.
* @throws RuntimeException if the constaint was not valid.
* @param s The string to parse. <b>Must be lower case and trimmed</b>.
* @throws RuntimeException if the constraint was not valid.
* @return The parsed constraint. Never <code>null</code>.
*/
public static CC parseComponentConstraint(String s)
{
CC cc = new CC();
if (s.length() == 0)
if (s == null || s.isEmpty())
return cc;
String[] parts = toTrimmedTokens(s, ',');
......@@ -550,16 +554,16 @@ public final class ConstraintParser
ix = startsWithLenient(part, "shrink", 6, false);
if (ix > -1) {
String[] shrinks = toTrimmedTokens(part.substring(ix).trim(), ' ');
cc.getHorizontal().setShrink(parseFloat(part.substring(ix).trim(), ResizeConstraint.WEIGHT_100));
cc.getHorizontal().setShrink(parseFloat(shrinks[0], ResizeConstraint.WEIGHT_100));
if (shrinks.length > 1)
cc.getVertical().setShrink(parseFloat(part.substring(ix).trim(), ResizeConstraint.WEIGHT_100));
cc.getVertical().setShrink(parseFloat(shrinks[1], ResizeConstraint.WEIGHT_100));
continue;
}
ix = startsWithLenient(part, new String[]{"shrinkprio", "shp"}, new int[]{10, 3}, true);
if (ix > -1) {
String sp = part.substring(ix).trim();
if (sp.startsWith("x") || sp.startsWith("y")) { // To gandle "gpx", "gpy", "shrinkpriorityx", shrinkpriorityy"
if (sp.startsWith("x") || sp.startsWith("y")) { // To handle "gpx", "gpy", "shrinkpriorityx", shrinkpriorityy"
(sp.startsWith("x") ? cc.getHorizontal() : cc.getVertical()).setShrinkPriority(Integer.parseInt(sp.substring(2)));
} else {
String[] shrinks = toTrimmedTokens(sp, ' ');
......@@ -607,7 +611,7 @@ public final class ConstraintParser
if (ix > -1) {
String gp = part.substring(ix).trim();
char c0 = gp.length() > 0 ? gp.charAt(0) : ' ';
if (c0 == 'x' || c0 == 'y') { // To gandle "gpx", "gpy", "growpriorityx", growpriorityy"
if (c0 == 'x' || c0 == 'y') { // To handle "gpx", "gpy", "growpriorityx", growpriorityy"
(c0 == 'x' ? cc.getHorizontal() : cc.getVertical()).setGrowPriority(Integer.parseInt(gp.substring(2)));
} else {
String[] grows = toTrimmedTokens(gp, ' ');
......@@ -857,6 +861,19 @@ public final class ConstraintParser
}
}
if (c == 'v') {
ix = startsWithLenient(part, new String[] {"visualpadding", "vp"}, new int[] {3, 2}, true);
if (ix > -1) {
UnitValue[] p = parseInsets(part.substring(ix).trim(), false);
cc.setVisualPadding(new UnitValue[] {
p[0],
p.length > 1 ? p[1] : null,
p.length > 2 ? p[2] : null,
p.length > 3 ? p[3] : null});
continue;
}
}
UnitValue horAlign = parseAlignKeywords(part, true);
if (horAlign != null) {
cc.getHorizontal().setAlign(horAlign);
......@@ -872,7 +889,7 @@ public final class ConstraintParser
throw new IllegalArgumentException("Unknown keyword.");
} catch (Exception ex) {
throw new IllegalArgumentException("Illegal Constraint: '" + part + "'\n" + ex.getMessage());
throw new IllegalArgumentException("Error parsing Constraint: '" + part + "'", ex);
}
}
......@@ -891,7 +908,7 @@ public final class ConstraintParser
{
if (s.length() == 0 || s.equals("dialog") || s.equals("panel")) {
if (acceptPanel == false)
throw new IllegalAccessError("Insets now allowed: " + s + "\n");
throw new IllegalArgumentException("Insets now allowed: " + s + "\n");
boolean isPanel = s.startsWith("p");
UnitValue[] ins = new UnitValue[4];
......@@ -1140,7 +1157,7 @@ public final class ConstraintParser
return new UnitValue(value, numParts[1], isHor, oper, cs);
} catch(Exception e) {
throw new IllegalArgumentException("Malformed UnitValue: '" + s + "'");
throw new IllegalArgumentException("Malformed UnitValue: '" + s + "'", e);
}
}
}
......
......@@ -60,8 +60,8 @@ public interface ContainerWrapper extends ComponentWrapper
public abstract boolean isLeftToRight();
/** Paints a cell to indicate where it is.
* @param x The x coordinate to start the drwaing.
* @param y The x coordinate to start the drwaing.
* @param x The x coordinate to start the drawing.
* @param y The x coordinate to start the drawing.
* @param width The width to draw/fill
* @param height The height to draw/fill
*/
......
package net.miginfocom.layout;
import java.io.*;
import java.io.Externalizable;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
import java.io.ObjectStreamException;
/*
* License (BSD):
* ==============
......@@ -218,7 +222,7 @@ public final class DimConstraint implements Externalizable
* <p>
* For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
* @param size The new gap.
* @see net.miginfocom.layout.ConstraintParser#parseBoundSize(String, boolean, boolean).
* @see net.miginfocom.layout.ConstraintParser#parseBoundSize(String, boolean, boolean)
*/
public void setGapAfter(BoundSize size)
{
......@@ -249,9 +253,9 @@ public final class DimConstraint implements Externalizable
/** Sets the gap before this entity. The gap is an empty space and can have a min/preferred/maximum size so that it can shrink and
* grow depending on available space. Gaps are against other entities' edges and not against other entities' gaps.
* <p>
* See also {@link net.miginfocom.layout.ConstraintParser#parseBoundSize(String, boolean, boolean)}.
* For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
* @param size The new gap.
* @see net.miginfocom.layout.ConstraintParser#parseBoundSize(String, boolean, boolean).
*/
public void setGapBefore(BoundSize size)
{
......@@ -270,9 +274,9 @@ public final class DimConstraint implements Externalizable
/** Returns the min/preferred/max size for the entity in the dimension that this object describes.
* <p>
* See also {@link net.miginfocom.layout.ConstraintParser#parseBoundSize(String, boolean, boolean)}.
* For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
* @return The current size. Never <code>null</code> since v3.5.
* @see net.miginfocom.layout.ConstraintParser#parseBoundSize(String, boolean, boolean).
*/
public BoundSize getSize()
{
......@@ -293,7 +297,7 @@ public final class DimConstraint implements Externalizable
/** Returns the size group that this entity should be in for the dimension that this object is describing.
* If this constraint is in a size group that is specified here. <code>null</code> means no size group
* and all other values are legal. Comparison with .equals(). Components/columnss/rows in the same size group
* and all other values are legal. Comparison with .equals(). Components/columns/rows in the same size group
* will have the same min/preferred/max size; that of the largest in the group for the first two and the
* smallest for max.
* <p>
......@@ -307,7 +311,7 @@ public final class DimConstraint implements Externalizable
/** Sets the size group that this entity should be in for the dimension that this object is describing.
* If this constraint is in a size group that is specified here. <code>null</code> means no size group
* and all other values are legal. Comparison with .equals(). Components/columnss/rows in the same size group
* and all other values are legal. Comparison with .equals(). Components/columns/rows in the same size group
* will have the same min/preferred/max size; that of the largest in the group for the first two and the
* smallest for max.
* <p>
......@@ -321,7 +325,7 @@ public final class DimConstraint implements Externalizable
// ************** Only applicable on components ! *******************
/** Returns the end group that this entity should be in for the demension that this object is describing.
/** Returns the end group that this entity should be in for the dimension that this object is describing.
* If this constraint is in an end group that is specified here. <code>null</code> means no end group
* and all other values are legal. Comparison with .equals(). Components in the same end group
* will have the same end coordinate.
......@@ -334,7 +338,7 @@ public final class DimConstraint implements Externalizable
return endGroup;
}
/** Sets the end group that this entity should be in for the demension that this object is describing.
/** Sets the end group that this entity should be in for the dimension that this object is describing.
* If this constraint is in an end group that is specified here. <code>null</code> means no end group
* and all other values are legal. Comparison with .equals(). Components in the same end group
* will have the same end coordinate.
......@@ -353,7 +357,7 @@ public final class DimConstraint implements Externalizable
* this constraint represents (width for column and height for a row).
* <p>
* For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
* @return code>true</code> means that components should grow.
* @return <code>true</code> means that components should grow.
*/
public boolean isFill()
{
......@@ -458,11 +462,13 @@ public final class DimConstraint implements Externalizable
return LayoutUtil.getSerializedObject(this);
}
@Override
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
{
LayoutUtil.setSerializedObject(this, LayoutUtil.readAsXML(in));
}
@Override
public void writeExternal(ObjectOutput out) throws IOException
{
if (getClass() == DimConstraint.class)
......
This diff is collapsed.
......@@ -39,6 +39,7 @@ package net.miginfocom.layout;
* E.g.:
*
* <pre>
* {@code
* if (adjacentComp == null || adjacentSide == SwingConstants.LEFT || adjacentSide == SwingConstants.TOP)
* return null;
*
......@@ -48,7 +49,8 @@ package net.miginfocom.layout;
* return isHor ? UNRELATED_Y : UNRELATED_Y;
*
* return (adjacentSide == SwingConstants.LEFT || adjacentSide == SwingConstants.RIGHT) ? RELATED_X : RELATED_Y;
* </pre
* }
* </pre>
*/
public interface InCellGapProvider
{
......
......@@ -45,7 +45,7 @@ public final class LC implements Externalizable
private Boolean leftToRight = null;
private UnitValue[] insets = null; // Never null elememts but if unset array is null
private UnitValue[] insets = null; // Never null elements but if unset array is null
private UnitValue alignX = null, alignY = null;
......@@ -244,7 +244,7 @@ public final class LC implements Externalizable
/** How a component that is hidden (not visible) should be treated by default.
* @return The mode:<br>
* 0 == Normal. Bounds will be caclulated as if the component was visible.<br>
* 0 == Normal. Bounds will be calculated as if the component was visible.<br>
* 1 == If hidden the size will be 0, 0 but the gaps remain.<br>
* 2 == If hidden the size will be 0, 0 and gaps set to zero.<br>
* 3 == If hidden the component will be disregarded completely and not take up a cell in the grid..
......@@ -256,7 +256,7 @@ public final class LC implements Externalizable
/** How a component that is hidden (not visible) should be treated.
* @param mode The mode:<br>
* 0 == Normal. Bounds will be caclulated as if the component was visible.<br>
* 0 == Normal. Bounds will be calculated as if the component was visible.<br>
* 1 == If hidden the size will be 0, 0 but the gaps remain.<br>
* 2 == If hidden the size will be 0, 0 and gaps set to zero.<br>
* 3 == If hidden the component will be disregarded completely and not take up a cell in the grid..
......@@ -326,7 +326,7 @@ public final class LC implements Externalizable
this.noGrid = b;
}
/** If the layout should go from the default top-to-bottom in the grid instead of the optinal bottom-to-top.
/** If the layout should go from the default top-to-bottom in the grid instead of the optional bottom-to-top.
* @return <code>true</code> for the default top-to-bottom.
*/
public final boolean isTopToBottom()
......@@ -334,7 +334,7 @@ public final class LC implements Externalizable
return topToBottom;
}
/** If the layout should go from the default top-to-bottom in the grid instead of the optinal bottom-to-top.
/** If the layout should go from the default top-to-bottom in the grid instead of the optional bottom-to-top.
* @param b <code>true</code> for the default top-to-bottom.
*/
public final void setTopToBottom(boolean b)
......@@ -378,7 +378,7 @@ public final class LC implements Externalizable
/** Returns the "pack width" for the <b>window</b> that this container is located in. When the size of this container changes
* the size of the window will be corrected to be within this BoundsSize. It can be used to set the minimum and/or maximum size of the window
* as well as the size window should optimally get. This optimal size is normaly its "preferred" size which is why "preferred"
* as well as the size window should optimally get. This optimal size is normally its "preferred" size which is why "preferred"
* is the normal value to set here.
* <p>
* ":push" can be appended to the bound size to only push the size bigger and never shrink it if the preferred size gets smaller.
......@@ -394,7 +394,7 @@ public final class LC implements Externalizable
/** Sets the "pack width" for the <b>window</b> that this container is located in. When the size of this container changes
* the size of the window will be corrected to be within this BoundsSize. It can be used to set the minimum and/or maximum size of the window
* as well as the size window should optimally get. This optimal size is normaly its "preferred" size which is why "preferred"
* as well as the size window should optimally get. This optimal size is normally its "preferred" size which is why "preferred"
* is the normal value to set here.
* <p>
* ":push" can be appended to the bound size to only push the size bigger and never shrink it if the preferred size gets smaller.
......@@ -410,7 +410,7 @@ public final class LC implements Externalizable
/** Returns the "pack height" for the <b>window</b> that this container is located in. When the size of this container changes
* the size of the window will be corrected to be within this BoundsSize. It can be used to set the minimum and/or maximum size of the window
* as well as the size window should optimally get. This optimal size is normaly its "preferred" size which is why "preferred"
* as well as the size window should optimally get. This optimal size is normally its "preferred" size which is why "preferred"
* is the normal value to set here.
* <p>
* ":push" can be appended to the bound size to only push the size bigger and never shrink it if the preferred size gets smaller.
......@@ -426,7 +426,7 @@ public final class LC implements Externalizable
/** Sets the "pack height" for the <b>window</b> that this container is located in. When the size of this container changes
* the size of the window will be corrected to be within this BoundsSize. It can be used to set the minimum and/or maximum size of the window
* as well as the size window should optimally get. This optimal size is normaly its "preferred" size which is why "preferred"
* as well as the size window should optimally get. This optimal size is normally its "preferred" size which is why "preferred"
* is the normal value to set here.
* <p>
* ":push" can be appended to the bound size to only push the size bigger and never shrink it if the preferred size gets smaller.
......@@ -442,7 +442,7 @@ public final class LC implements Externalizable
/** If there is a resize of the window due to packing (see {@link #setPackHeight(BoundSize)} this value, which is between 0f and 1f,
* decides where the extra/surpurflous size is placed. 0f means that the window will resize so that the upper part moves up and the
* decides where the extra/superfluous size is placed. 0f means that the window will resize so that the upper part moves up and the
* lower side stays in the same place. 0.5f will expand/reduce the window equally upwards and downwards. 1f will do the opposite of 0f
* of course.
* @return The pack alignment. Always between 0f and 1f, inclusive.
......@@ -454,7 +454,7 @@ public final class LC implements Externalizable
}
/** If there is a resize of the window due to packing (see {@link #setPackHeight(BoundSize)} this value, which is between 0f and 1f,
* decides where the extra/surpurflous size is placed. 0f means that the window will resize so that the upper part moves up and the
* decides where the extra/superfluous size is placed. 0f means that the window will resize so that the upper part moves up and the
* lower side stays in the same place. 0.5f will expand/reduce the window equally upwards and downwards. 1f will do the opposite of 0f
* of course.
* @param align The pack alignment. Always between 0f and 1f, inclusive. Values outside this will be truncated.
......@@ -466,7 +466,7 @@ public final class LC implements Externalizable
}
/** If there is a resize of the window due to packing (see {@link #setPackHeight(BoundSize)} this value, which is between 0f and 1f,
* decides where the extra/surpurflous size is placed. 0f means that the window will resize so that the left part moves left and the
* decides where the extra/superfluous size is placed. 0f means that the window will resize so that the left part moves left and the
* right side stays in the same place. 0.5f will expand/reduce the window equally to the right and lefts. 1f will do the opposite of 0f
* of course.
* @return The pack alignment. Always between 0f and 1f, inclusive.
......@@ -478,7 +478,7 @@ public final class LC implements Externalizable
}
/** If there is a resize of the window due to packing (see {@link #setPackHeight(BoundSize)} this value, which is between 0f and 1f,
* decides where the extra/surpurflous size is placed. 0f means that the window will resize so that the left part moves left and the
* decides where the extra/superfluous size is placed. 0f means that the window will resize so that the left part moves left and the
* right side stays in the same place. 0.5f will expand/reduce the window equally to the right and lefts. 1f will do the opposite of 0f
* of course.
* @param align The pack alignment. Always between 0f and 1f, inclusive. Values outside this will be truncated.
......@@ -490,7 +490,7 @@ public final class LC implements Externalizable
}
/** Returns the minimum/preferred/maximum size for the container that this layout constraint is set for. Any of these
* sizes that is not <code>null</code> will be returned directly instead of determining the correspondig size through
* sizes that is not <code>null</code> will be returned directly instead of determining the corresponding size through
* asking the components in this container.
* @return The width for the container that this layout constraint is set for. Not <code>null</code> but
* all sizes can be <code>null</code>.
......@@ -502,7 +502,7 @@ public final class LC implements Externalizable
}
/** Sets the minimum/preferred/maximum size for the container that this layout constraint is set for. Any of these
* sizes that is not <code>null</code> will be returned directly instead of determining the correspondig size through
* sizes that is not <code>null</code> will be returned directly instead of determining the corresponding size through
* asking the components in this container.
* @param size The width for the container that this layout constraint is set for. <code>null</code> is translated to
* a bound size containing only null sizes.
......@@ -514,7 +514,7 @@ public final class LC implements Externalizable
}
/** Returns the minimum/preferred/maximum size for the container that this layout constraint is set for. Any of these
* sizes that is not <code>null</code> will be returned directly instead of determining the correspondig size through
* sizes that is not <code>null</code> will be returned directly instead of determining the corresponding size through
* asking the components in this container.
* @return The height for the container that this layout constraint is set for. Not <code>null</code> but
* all sizes can be <code>null</code>.
......@@ -526,7 +526,7 @@ public final class LC implements Externalizable
}
/** Sets the minimum/preferred/maximum size for the container that this layout constraint is set for. Any of these
* sizes that is not <code>null</code> will be returned directly instead of determining the correspondig size through
* sizes that is not <code>null</code> will be returned directly instead of determining the corresponding size through
* asking the components in this container.
* @param size The height for the container that this layout constraint is set for. <code>null</code> is translated to
* a bound size containing only null sizes.
......@@ -568,7 +568,7 @@ public final class LC implements Externalizable
*/
public final LC pack(String width, String height)
{
setPackWidth(width != null ? ConstraintParser.parseBoundSize(width, false, false) : BoundSize.NULL_SIZE);
setPackWidth(width != null ? ConstraintParser.parseBoundSize(width, false, true) : BoundSize.NULL_SIZE);
setPackHeight(height != null ? ConstraintParser.parseBoundSize(height, false, false) : BoundSize.NULL_SIZE);
return this;
}
......@@ -593,7 +593,7 @@ public final class LC implements Externalizable
/** Sets a wrap after the number of columns/rows that is defined in the {@link net.miginfocom.layout.AC}.
* <p>
* Same functionality as {@link #setWrapAfter(int 0)} only this method returns <code>this</code> for chaining multiple calls.
* Same functionality as calling {@link #setWrapAfter(int)} with <code>0</code> only this method returns <code>this</code> for chaining multiple calls.
* <p>
* For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
* @return <code>this</code> so it is possible to chain calls. E.g. <code>new LayoutConstraint().noGrid().gap().fill()</code>.
......@@ -616,7 +616,7 @@ public final class LC implements Externalizable
return this;
}
/** Same functionality as {@link #setNoCache(boolean true)} only this method returns <code>this</code> for chaining multiple calls.
/** Same functionality as calling {@link #setNoCache(boolean)} with <code>true</code> only this method returns <code>this</code> for chaining multiple calls.
* <p>
* For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
* @return <code>this</code> so it is possible to chain calls. E.g. <code>new LayoutConstraint().noGrid().gap().fill()</code>.
......@@ -627,7 +627,7 @@ public final class LC implements Externalizable
return this;
}
/** Same functionality as {@link #setFlowX(boolean false)} only this method returns <code>this</code> for chaining multiple calls.
/** Same functionality as calling {@link #setFlowX(boolean)} with <code>false</code> only this method returns <code>this</code> for chaining multiple calls.
* <p>
* For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
* @return <code>this</code> so it is possible to chain calls. E.g. <code>new LayoutConstraint().noGrid().gap().fill()</code>.
......@@ -638,7 +638,7 @@ public final class LC implements Externalizable
return this;
}
/** Same functionality as {@link #setFlowX(boolean true)} only this method returns <code>this</code> for chaining multiple calls.
/** Same functionality as calling {@link #setFlowX(boolean)} with <code>true</code> only this method returns <code>this</code> for chaining multiple calls.
* <p>
* For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
* @return <code>this</code> so it is possible to chain calls. E.g. <code>new LayoutConstraint().noGrid().gap().fill()</code>.
......@@ -649,7 +649,7 @@ public final class LC implements Externalizable
return this;
}
/** Same functionality as {@link #setFillX(boolean true)} and {@link #setFillY(boolean true)} conmbined.T his method returns
/** Same functionality as calling {@link #setFillX(boolean)} with <code>true</code> and {@link #setFillY(boolean)} with <code>true</code> conmbined.T his method returns
* <code>this</code> for chaining multiple calls.
* <p>
* For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
......@@ -662,7 +662,7 @@ public final class LC implements Externalizable
return this;
}
/** Same functionality as {@link #setFillX(boolean true)} only this method returns <code>this</code> for chaining multiple calls.
/** Same functionality as calling {@link #setFillX(boolean)} with <code>true</code> only this method returns <code>this</code> for chaining multiple calls.
* <p>
* For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
* @return <code>this</code> so it is possible to chain calls. E.g. <code>new LayoutConstraint().noGrid().gap().fill()</code>.
......@@ -673,7 +673,7 @@ public final class LC implements Externalizable
return this;
}
/** Same functionality as {@link #setFillY(boolean true)} only this method returns <code>this</code> for chaining multiple calls.
/** Same functionality as calling {@link #setFillY(boolean)} with <code>true</code> only this method returns <code>this</code> for chaining multiple calls.
* <p>
* For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
* @return <code>this</code> so it is possible to chain calls. E.g. <code>new LayoutConstraint().noGrid().gap().fill()</code>.
......@@ -708,7 +708,7 @@ public final class LC implements Externalizable
return this;
}
/** Same functionality as {@link #setTopToBottom(boolean false)} only this method returns <code>this</code> for chaining multiple calls.
/** Same functionality as calling {@link #setTopToBottom(boolean)} with <code>false</code> only this method returns <code>this</code> for chaining multiple calls.
* <p>
* For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
* @return <code>this</code> so it is possible to chain calls. E.g. <code>new LayoutConstraint().noGrid().gap().fill()</code>.
......@@ -719,7 +719,7 @@ public final class LC implements Externalizable
return this;
}
/** Same functionality as {@link #setTopToBottom(boolean true)} only this method returns <code>this</code> for chaining multiple calls.
/** Same functionality as calling {@link #setTopToBottom(boolean)} with <code>true</code> only this method returns <code>this</code> for chaining multiple calls.
* <p>
* For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
* @return <code>this</code> so it is possible to chain calls. E.g. <code>new LayoutConstraint().noGrid().gap().fill()</code>.
......@@ -731,7 +731,7 @@ public final class LC implements Externalizable
return this;
}
/** Same functionality as {@link #setNoGrid(boolean true)} only this method returns <code>this</code> for chaining multiple calls.
/** Same functionality as calling {@link #setNoGrid(boolean)} with <code>true</code> only this method returns <code>this</code> for chaining multiple calls.
* <p>
* For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
* @return <code>this</code> so it is possible to chain calls. E.g. <code>new LayoutConstraint().noGrid().gap().fill()</code>.
......@@ -742,7 +742,7 @@ public final class LC implements Externalizable
return this;
}
/** Same functionality as {@link #setVisualPadding(boolean false)} only this method returns <code>this</code> for chaining multiple calls.
/** Same functionality as calling {@link #setVisualPadding(boolean)} with <code>false</code> only this method returns <code>this</code> for chaining multiple calls.
* <p>
* For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
* @return <code>this</code> so it is possible to chain calls. E.g. <code>new LayoutConstraint().noGrid().gap().fill()</code>.
......@@ -906,6 +906,16 @@ public final class LC implements Externalizable
return this;
}
/** Calls {@link #debug(int)} with 300 as an argument.
* @return <code>this</code> so it is possible to chain calls. E.g. <code>new LayoutConstraint().noGrid().gap().fill()</code>.
* @see #setDebugMillis(int)
*/
public final LC debug()
{
setDebugMillis(300);
return this;
}
/** Same functionality as {@link #setDebugMillis(int repaintMillis)} only this method returns <code>this</code> for chaining multiple calls.
* <p>
* For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
......@@ -1019,11 +1029,13 @@ public final class LC implements Externalizable
return LayoutUtil.getSerializedObject(this);
}
@Override
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
{
LayoutUtil.setSerializedObject(this, LayoutUtil.readAsXML(in));
}
@Override
public void writeExternal(ObjectOutput out) throws IOException
{
if (getClass() == LC.class)
......
File mode changed from 100644 to 100755
......@@ -43,7 +43,7 @@ import java.util.WeakHashMap;
*/
public final class LayoutUtil
{
/** A substitute value for aa really large value. Integer.MAX_VALUE is not used since that means a lot of defensive code
/** A substitute value for a really large value. Integer.MAX_VALUE is not used since that means a lot of defensive code
* for potential overflow must exist in many places. This value is large enough for being unreasonable yet it is hard to
* overflow.
*/
......@@ -58,6 +58,9 @@ public final class LayoutUtil
public static final int PREF = 1;
public static final int MAX = 2;
public static final int HORIZONTAL = 0;
public static final int VERTICAL = 1;
private static volatile WeakHashMap<Object, String> CR_MAP = null;
private static volatile WeakHashMap<Object, Boolean> DT_MAP = null; // The Containers that have design time. Value not used.
private static int eSz = 0;
......@@ -83,7 +86,7 @@ public final class LayoutUtil
*/
public static String getVersion()
{
return "4.2";
return "5.0";
}
/** If global debug should be on or off. If &gt; 0 then debug is turned on for all MigLayout
......@@ -139,6 +142,11 @@ public final class LayoutUtil
if (DT_MAP == null)
return HAS_BEANS && Beans.isDesignTime();
// assume design time "in general" (cw is null) if there is at least one container with design time
// (for storing constraints creation strings in method putCCString())
if (cw == null && DT_MAP != null && !DT_MAP.isEmpty() )
return true;
if (cw != null && DT_MAP.containsKey(cw.getComponent()) == false)
cw = null;
......@@ -183,10 +191,10 @@ public final class LayoutUtil
}
/** Sets/add the persistence delegates to be used for a class.
* @param c The class to set the registered deligate for.
* @param c The class to set the registered delegate for.
* @param del The new delegate or <code>null</code> to erase to old one.
*/
static synchronized void setDelegate(Class c, PersistenceDelegate del)
static synchronized void setDelegate(Class<?> c, PersistenceDelegate del)
{
try {
Introspector.getBeanInfo(c, Introspector.IGNORE_ALL_BEANINFO).getBeanDescriptor().setValue("persistenceDelegate", del);
......@@ -210,7 +218,7 @@ public final class LayoutUtil
}
/** Takes a number on min/preferred/max sizes and resize constraints and returns the calculated sizes which sum should add up to <code>bounds</code>. Whether the sum
* will actually equal <code>bounds</code> is dependent om the pref/max sizes and resize constraints.
* will actually equal <code>bounds</code> is dependent on the pref/max sizes and resize constraints.
* @param sizes [ix],[MIN][PREF][MAX]. Grid.CompWrap.NOT_SET will be treated as N/A or 0. A "[MIN][PREF][MAX]" array with null elements will be interpreted as very flexible (no bounds)
* but if the array itself is null it will not get any size.
* @param resConstr Elements can be <code>null</code> and the whole array can be <code>null</code>. <code>null</code> means that the size will not be flexible at all.
......@@ -324,8 +332,8 @@ public final class LayoutUtil
* are broken, the lower one is returned. If <code>sz</code> is &lt; 0 then <code>new Float(0f)</code> is returned so that no sizes can be
* negative.
* @param sz The size to check
* @param lower The lower boundary (or <code>null</code> fo no boundary).
* @param upper The upper boundary (or <code>null</code> fo no boundary).
* @param lower The lower boundary (or <code>null</code> for no boundary).
* @param upper The upper boundary (or <code>null</code> for no boundary).
* @return The broken boundary.
*/
private static int getBrokenBoundary(float sz, int lower, int upper)
......@@ -357,6 +365,28 @@ public final class LayoutUtil
return sum(terms, 0, terms.length);
}
/** Keeps f within min and max. Min is of higher priority if min is larger than max.
* @param f The value to clamp
* @param min
* @param max
* @return The clamped value, between min and max.
*/
static float clamp(float f, float min, float max)
{
return Math.max(min, Math.min(f, max));
}
/** Keeps i within min and max. Min is of higher priority if min is larger than max.
* @param i The value to clamp
* @param min
* @param max
* @return The clamped value, between min and max.
*/
static int clamp(int i, int min, int max)
{
return Math.max(min, Math.min(i, max));
}
public static int getSizeSafe(int[] sizes, int sizeType)
{
if (sizes == null || sizes[sizeType] == NOT_SET)
......@@ -380,7 +410,7 @@ public final class LayoutUtil
/** Returns if left-to-right orientation is used. If not set explicitly in the layout constraints the Locale
* of the <code>parent</code> is used.
* @param lc The constraint if there is one. Can be <code>null</code>.
* @param container The parent that may be used to get the left-to-right if ffc does not specify this.
* @param container The parent that may be used to get the left-to-right if lc does not specify this.
* @return If left-to-right orientation is currently used.
*/
public static boolean isLeftToRight(LC lc, ContainerWrapper container)
......@@ -446,10 +476,10 @@ public final class LayoutUtil
// }
/** Returns the inset for the side.
/** Returns the insets for the side.
* @param side top == 0, left == 1, bottom = 2, right = 3.
* @param getDefault If <code>true</code> the default insets will get retrieved if <code>lc</code> has none set.
* @return The inset for the side. Never <code>null</code>.
* @return The insets for the side. Never <code>null</code>.
*/
static UnitValue getInsets(LC lc, int side, boolean getDefault)
{
......@@ -457,10 +487,10 @@ public final class LayoutUtil
return (i != null && i[side] != null) ? i[side] : (getDefault ? PlatformDefaults.getPanelInsets(side) : UnitValue.ZERO);
}
/** Writes the objet and CLOSES the stream. Uses the persistence delegate registered in this class.
/** Writes the object and CLOSES the stream. Uses the persistence delegate registered in this class.
* @param os The stream to write to. Will be closed.
* @param o The object to be serialized.
* @param listener The listener to recieve the exeptions if there are any. If <code>null</code> not used.
* @param listener The listener to receive the exceptions if there are any. If <code>null</code> not used.
*/
static void writeXMLObject(OutputStream os, Object o, ExceptionListener listener)
{
......@@ -480,7 +510,7 @@ public final class LayoutUtil
private static ByteArrayOutputStream writeOutputStream = null;
/** Writes an object to XML.
* @param out The boject out to write to. Will not be closed.
* @param out The object out to write to. Will not be closed.
* @param o The object to write.
*/
public static synchronized void writeAsXML(ObjectOutput out, Object o) throws IOException
......@@ -491,6 +521,7 @@ public final class LayoutUtil
writeOutputStream.reset();
writeXMLObject(writeOutputStream, o, new ExceptionListener() {
@Override
public void exceptionThrown(Exception e) {
e.printStackTrace();
}});
......
package net.miginfocom.layout;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.WeakHashMap;
/*
* License (BSD):
* ==============
......@@ -48,9 +47,11 @@ public final class LinkHandler
public static final int X2 = 4;
public static final int Y2 = 5;
private static final ArrayList<WeakReference<Object>> LAYOUTS = new ArrayList<WeakReference<Object>>(4);
private static final ArrayList<HashMap<String, int[]>> VALUES = new ArrayList<HashMap<String, int[]>>(4);
private static final ArrayList<HashMap<String, int[]>> VALUES_TEMP = new ArrayList<HashMap<String, int[]>>(4);
// indices for values of LAYOUTS
private static final int VALUES = 0;
private static final int VALUES_TEMP = 1;
private static final WeakHashMap<Object, HashMap<String, int[]>[]> LAYOUTS = new WeakHashMap<Object, HashMap<String, int[]>[]>();
private LinkHandler()
{
......@@ -59,26 +60,16 @@ public final class LinkHandler
public synchronized static Integer getValue(Object layout, String key, int type)
{
Integer ret = null;
boolean cont = true;
for (int i = LAYOUTS.size() - 1; i >= 0; i--) {
Object l = LAYOUTS.get(i).get();
if (ret == null && l == layout) {
int[] rect = VALUES_TEMP.get(i).get(key);
if (cont && rect != null && rect[type] != LayoutUtil.NOT_SET) {
HashMap<String, int[]>[] layoutValues = LAYOUTS.get(layout);
if (layoutValues != null) {
int[] rect = layoutValues[VALUES_TEMP].get(key);
if (rect != null && rect[type] != LayoutUtil.NOT_SET) {
ret = rect[type];
} else {
rect = VALUES.get(i).get(key);
rect = layoutValues[VALUES].get(key);
ret = (rect != null && rect[type] != LayoutUtil.NOT_SET) ? rect[type] : null;
}
cont = false;
}
if (l == null) {
LAYOUTS.remove(i);
VALUES.remove(i);
VALUES_TEMP.remove(i);
}
}
return ret;
}
......@@ -99,10 +90,9 @@ public final class LinkHandler
synchronized static boolean setBounds(Object layout, String key, int x, int y, int width, int height, boolean temporary, boolean incCur)
{
for (int i = LAYOUTS.size() - 1; i >= 0; i--) {
Object l = LAYOUTS.get(i).get();
if (l == layout) {
HashMap<String, int[]> map = (temporary ? VALUES_TEMP : VALUES).get(i);
HashMap<String, int[]>[] layoutValues = LAYOUTS.get(layout);
if (layoutValues != null) {
HashMap<String, int[]> map = layoutValues[temporary ? VALUES_TEMP : VALUES];
int[] old = map.get(key);
if (old == null || old[X] != x || old[Y] != y || old[WIDTH] != width || old[HEIGHT] != height) {
......@@ -150,20 +140,18 @@ public final class LinkHandler
}
return false;
}
}
LAYOUTS.add(new WeakReference<Object>(layout));
int[] bounds = new int[] {x, y, width, height, x + width, y + height};
HashMap<String, int[]> values = new HashMap<String, int[]>(4);
HashMap<String, int[]> values_temp = new HashMap<String, int[]>(4);
if (temporary)
values.put(key, bounds);
VALUES_TEMP.add(values);
values_temp.put(key, bounds);
values = new HashMap<String, int[]>(4);
HashMap<String, int[]> values = new HashMap<String, int[]>(4);
if (temporary == false)
values.put(key, bounds);
VALUES.add(values);
LAYOUTS.put(layout, new HashMap[] {values, values_temp});
return true;
}
......@@ -179,22 +167,16 @@ public final class LinkHandler
public synchronized static boolean clearBounds(Object layout, String key)
{
for (int i = LAYOUTS.size() - 1; i >= 0; i--) {
Object l = LAYOUTS.get(i).get();
if (l == layout)
return VALUES.get(i).remove(key) != null;
}
HashMap<String, int[]>[] layoutValues = LAYOUTS.get(layout);
if (layoutValues != null)
return layoutValues[VALUES].remove(key) != null;
return false;
}
synchronized static void clearTemporaryBounds(Object layout)
{
for (int i = LAYOUTS.size() - 1; i >= 0; i--) {
Object l = LAYOUTS.get(i).get();
if (l == layout) {
VALUES_TEMP.get(i).clear();
return;
}
}
HashMap<String, int[]>[] layoutValues = LAYOUTS.get(layout);
if (layoutValues != null)
layoutValues[VALUES_TEMP].clear();
}
}
package net.miginfocom.layout;
import javax.swing.*;
import java.util.HashMap;
/*
* License (BSD):
* ==============
......@@ -42,6 +42,12 @@ import java.util.HashMap;
*/
public final class PlatformDefaults
{
/** Property to use in LAF settings and as JComponent client property
* to specify the visual padding.
* <p>
*/
public static String VISUAL_PADDING_PROPERTY = "visualPadding";
private static int DEF_H_UNIT = UnitValue.LPX;
private static int DEF_V_UNIT = UnitValue.LPY;
......@@ -49,28 +55,30 @@ public final class PlatformDefaults
private static volatile int MOD_COUNT = 0;
private static final UnitValue LPX4 = new UnitValue(4, UnitValue.LPX, null);
// private static final UnitValue LPX1 = new UnitValue(1, UnitValue.LPX, null);
// private static final UnitValue LPX4 = new UnitValue(4, UnitValue.LPX, null);
private static final UnitValue LPX6 = new UnitValue(6, UnitValue.LPX, null);
private static final UnitValue LPX7 = new UnitValue(7, UnitValue.LPX, null);
// private static final UnitValue LPX8 = new UnitValue(8, UnitValue.LPX, null);
private static final UnitValue LPX9 = new UnitValue(9, UnitValue.LPX, null);
private static final UnitValue LPX10 = new UnitValue(10, UnitValue.LPX, null);
// private static final UnitValue LPX9 = new UnitValue(9, UnitValue.LPX, null);
// private static final UnitValue LPX10 = new UnitValue(10, UnitValue.LPX, null);
private static final UnitValue LPX11 = new UnitValue(11, UnitValue.LPX, null);
private static final UnitValue LPX12 = new UnitValue(12, UnitValue.LPX, null);
private static final UnitValue LPX14 = new UnitValue(14, UnitValue.LPX, null);
// private static final UnitValue LPX14 = new UnitValue(14, UnitValue.LPX, null);
private static final UnitValue LPX16 = new UnitValue(16, UnitValue.LPX, null);
private static final UnitValue LPX18 = new UnitValue(18, UnitValue.LPX, null);
private static final UnitValue LPX20 = new UnitValue(20, UnitValue.LPX, null);
private static final UnitValue LPY4 = new UnitValue(4, UnitValue.LPY, null);
// private static final UnitValue LPY1 = new UnitValue(1, UnitValue.LPY, null);
// private static final UnitValue LPY4 = new UnitValue(4, UnitValue.LPY, null);
private static final UnitValue LPY6 = new UnitValue(6, UnitValue.LPY, null);
private static final UnitValue LPY7 = new UnitValue(7, UnitValue.LPY, null);
// private static final UnitValue LPY8 = new UnitValue(8, UnitValue.LPY, null);
private static final UnitValue LPY9 = new UnitValue(9, UnitValue.LPY, null);
private static final UnitValue LPY10 = new UnitValue(10, UnitValue.LPY, null);
// private static final UnitValue LPY9 = new UnitValue(9, UnitValue.LPY, null);
// private static final UnitValue LPY10 = new UnitValue(10, UnitValue.LPY, null);
private static final UnitValue LPY11 = new UnitValue(11, UnitValue.LPY, null);
private static final UnitValue LPY12 = new UnitValue(12, UnitValue.LPY, null);
private static final UnitValue LPY14 = new UnitValue(14, UnitValue.LPY, null);
// private static final UnitValue LPY14 = new UnitValue(14, UnitValue.LPY, null);
private static final UnitValue LPY16 = new UnitValue(16, UnitValue.LPY, null);
private static final UnitValue LPY18 = new UnitValue(18, UnitValue.LPY, null);
private static final UnitValue LPY20 = new UnitValue(20, UnitValue.LPY, null);
......@@ -93,6 +101,7 @@ public final class PlatformDefaults
private static BoundSize DEF_VGAP = null, DEF_HGAP = null;
static BoundSize RELATED_X = null, RELATED_Y = null, UNRELATED_X = null, UNRELATED_Y = null;
private static UnitValue BUTT_WIDTH = null;
private static UnitValue BUTT_PADDING = null;
private static Float horScale = null, verScale = null;
......@@ -132,6 +141,8 @@ public final class PlatformDefaults
private static boolean dra = true;
private static final HashMap<String, int[]> VISUAL_BOUNDS = new HashMap<String, int[]>(64);
static {
setPlatform(getCurrentPlatform());
MOD_COUNT = 0;
......@@ -165,40 +176,70 @@ public final class PlatformDefaults
{
switch (plaf) {
case WINDOWS_XP:
setRelatedGap(LPX4, LPY4);
setUnrelatedGap(LPX7, LPY9);
setParagraphGap(LPX14, LPY14);
setIndentGap(LPX9, LPY9);
setGridCellGap(LPX4, LPY4);
setDefaultVisualPadding("TabbedPane." + VISUAL_PADDING_PROPERTY, new int[]{1, 0, 1, 2});
setRelatedGap(LPX7, LPY7);
setUnrelatedGap(LPX11, LPY11);
setParagraphGap(LPX20, LPY20);
setIndentGap(LPX11, LPY11);
setGridCellGap(LPX7, LPY7);
setMinimumButtonWidth(new UnitValue(75, UnitValue.LPX, null));
setButtonOrder("L_E+U+YNBXOCAH_R");
setButtonOrder("L_E+U+YNBXOCAH_I_R");
setDialogInsets(LPY11, LPX11, LPY11, LPX11);
setPanelInsets(LPY7, LPX7, LPY7, LPX7);
break;
case MAC_OSX:
setRelatedGap(LPX4, LPY4);
setUnrelatedGap(LPX7, LPY9);
setParagraphGap(LPX14, LPY14);
setIndentGap(LPX10, LPY10);
setGridCellGap(LPX4, LPY4);
setMinimumButtonWidth(new UnitValue(68, UnitValue.LPX, null));
setButtonOrder("L_HE+U+NYBXCOA_R");
setDialogInsets(LPY14, LPX20, LPY20, LPX20);
setPanelInsets(LPY16, LPX16, LPY16, LPX16);
// setRelatedGap(LPX8, LPY8);
// setUnrelatedGap(LPX12, LPY12);
// setParagraphGap(LPX16, LPY16);
// setIndentGap(LPX10, LPY10);
// setGridCellGap(LPX8, LPY8);
//
// setMinimumButtonWidth(new UnitValue(68, UnitValue.LPX, null));
// setButtonOrder("L_HE+U+NYBXCOA_R");
// setDialogInsets(LPY14, LPX20, LPY20, LPX20);
// setPanelInsets(LPY16, LPX16, LPY16, LPX16);
setDefaultVisualPadding("Button." + VISUAL_PADDING_PROPERTY, new int[]{3, 6, 5, 6});
setDefaultVisualPadding("Button.icon." + VISUAL_PADDING_PROPERTY, new int[]{3, 2, 3, 2});
setDefaultVisualPadding("Button.square." + VISUAL_PADDING_PROPERTY, new int[]{4, 4, 4, 4});
setDefaultVisualPadding("Button.square.icon." + VISUAL_PADDING_PROPERTY, new int[]{4, 4, 4, 4});
setDefaultVisualPadding("Button.gradient." + VISUAL_PADDING_PROPERTY, new int[]{5, 4, 5, 4});
setDefaultVisualPadding("Button.gradient.icon." + VISUAL_PADDING_PROPERTY, new int[]{5, 4, 5, 4});
setDefaultVisualPadding("Button.bevel." + VISUAL_PADDING_PROPERTY, new int[]{2, 2, 3, 2});
setDefaultVisualPadding("Button.bevel.icon." + VISUAL_PADDING_PROPERTY, new int[]{2, 2, 3, 2});
setDefaultVisualPadding("Button.textured." + VISUAL_PADDING_PROPERTY, new int[]{3, 2, 3, 2});
setDefaultVisualPadding("Button.textured.icon." + VISUAL_PADDING_PROPERTY, new int[]{3, 2, 3, 2});
setDefaultVisualPadding("Button.roundRect." + VISUAL_PADDING_PROPERTY, new int[]{5, 4, 5, 4});
setDefaultVisualPadding("Button.roundRect.icon." + VISUAL_PADDING_PROPERTY, new int[]{5, 4, 5, 4});
setDefaultVisualPadding("Button.recessed." + VISUAL_PADDING_PROPERTY, new int[]{5, 4, 5, 4});
setDefaultVisualPadding("Button.recessed.icon." + VISUAL_PADDING_PROPERTY, new int[]{5, 4, 5, 4});
setDefaultVisualPadding("Button.help." + VISUAL_PADDING_PROPERTY, new int[]{4, 3, 3, 4});
setDefaultVisualPadding("Button.help.icon." + VISUAL_PADDING_PROPERTY, new int[]{4, 3, 3, 4});
setDefaultVisualPadding("ComboBox." + VISUAL_PADDING_PROPERTY, new int[]{2, 4, 4, 5});
setDefaultVisualPadding("ComboBox.isPopDown." + VISUAL_PADDING_PROPERTY, new int[]{2, 5, 4, 5});
setDefaultVisualPadding("ComboBox.isSquare." + VISUAL_PADDING_PROPERTY, new int[]{1, 6, 5, 7});
setDefaultVisualPadding("ComboBox.editable." + VISUAL_PADDING_PROPERTY, new int[]{3, 3, 3, 2});
setDefaultVisualPadding("ComboBox.editable.isSquare." + VISUAL_PADDING_PROPERTY, new int[]{3, 3, 3, 1});
setDefaultVisualPadding("TextField." + VISUAL_PADDING_PROPERTY, new int[]{3, 3, 3, 3});
setDefaultVisualPadding("TabbedPane." + VISUAL_PADDING_PROPERTY, new int[]{4, 8, 11, 8});
setDefaultVisualPadding("Spinner." + VISUAL_PADDING_PROPERTY, new int[]{3, 3, 3, 1});
setDefaultVisualPadding("RadioButton." + VISUAL_PADDING_PROPERTY, new int[]{4, 6, 3, 5});
setDefaultVisualPadding("RadioButton.small." + VISUAL_PADDING_PROPERTY, new int[]{4, 6, 3, 5});
setDefaultVisualPadding("RadioButton.mini." + VISUAL_PADDING_PROPERTY, new int[]{5, 7, 4, 5});
setDefaultVisualPadding("CheckBox." + VISUAL_PADDING_PROPERTY, new int[]{5, 7, 4, 5});
setDefaultVisualPadding("CheckBox.small." + VISUAL_PADDING_PROPERTY, new int[]{5, 7, 4, 5});
setDefaultVisualPadding("CheckBox.mini." + VISUAL_PADDING_PROPERTY, new int[]{6, 7, 3, 5});
setRelatedGap(LPX7, LPY7);
setUnrelatedGap(LPX11, LPY11);
setParagraphGap(LPX20, LPY20);
setIndentGap(LPX11, LPY11);
setGridCellGap(LPX7, LPY7);
setMinimumButtonWidth(new UnitValue(70, UnitValue.LPX, null));
setMinimumButtonPadding(new UnitValue(8, UnitValue.LPX, null));
setButtonOrder("L_HE+U+NYBXCOA_I_R");
setDialogInsets(LPY20, LPX20, LPY20, LPX20);
setPanelInsets(LPY16, LPX16, LPY16, LPX16);
break;
case GNOME:
setRelatedGap(LPX6, LPY6); // GNOME HIG 8.2.3
setUnrelatedGap(LPX12, LPY12); // GNOME HIG 8.2.3
......@@ -208,7 +249,7 @@ public final class PlatformDefaults
// GtkButtonBox, child-min-width property default value
setMinimumButtonWidth(new UnitValue(85, UnitValue.LPX, null));
setButtonOrder("L_HE+UNYACBXIO_R"); // GNOME HIG 3.4.2, 3.7.1
setButtonOrder("L_HE+UNYACBXO_I_R"); // GNOME HIG 3.4.2, 3.7.1
setDialogInsets(LPY12, LPX12, LPY12, LPX12); // GNOME HIG 3.4.3
setPanelInsets(LPY6, LPX6, LPY6, LPX6); // ???
break;
......@@ -219,7 +260,27 @@ public final class PlatformDefaults
BASE_DPI = BASE_DPI_FORCED != null ? BASE_DPI_FORCED : getPlatformDPI(plaf);
}
private static int getPlatformDPI(int plaf)
/** Sets the visual bounds for a component type.
* @param key The component type. E.g. "TabbedPane.visualPadding" or "ComboBox.editable.isSquare.visualPadding". See source code for list.
* @param insets Top, left, bottom, right. Always length 4 or null.
* @see net.miginfocom.layout.ComponentWrapper#getVisualPadding()
*/
public static void setDefaultVisualPadding(String key, int[] insets)
{
VISUAL_BOUNDS.put(key, insets);
}
/** Returns the visual bounds for a component type.
* @param key The component type. E.g. "TabbedPane.visualPadding" or "ComboBox.editable.isSquare.visualPadding". See source code for list.
* @return insets Top, left, bottom, right. Always length 4 or null. Live object, MUST NOT BE CHANGED!.
* @see net.miginfocom.layout.ComponentWrapper#getVisualPadding()
*/
public static int[] getDefaultVisualPadding(String key)
{
return VISUAL_BOUNDS.get(key);
}
public static int getPlatformDPI(int plaf)
{
switch (plaf) {
case WINDOWS_XP:
......@@ -227,7 +288,7 @@ public final class PlatformDefaults
return 96;
case MAC_OSX:
try {
return System.getProperty("java.version").compareTo("1.6") < 0 ? 72 : 96; // Default DPI was 72 prior to JSE 1.6
return java.awt.Toolkit.getDefaultToolkit().getScreenResolution();
} catch (Throwable t) {
return 72;
}
......@@ -282,7 +343,7 @@ public final class PlatformDefaults
*/
public static void setHorizontalScaleFactor(Float f)
{
if (LayoutUtil.equals(horScale, f) == false) {
if (!LayoutUtil.equals(horScale, f)) {
horScale = f;
MOD_COUNT++;
}
......@@ -309,7 +370,7 @@ public final class PlatformDefaults
*/
public static void setVerticalScaleFactor(Float f)
{
if (LayoutUtil.equals(verScale, f) == false) {
if (!LayoutUtil.equals(verScale, f)) {
verScale = f;
MOD_COUNT++;
}
......@@ -335,7 +396,7 @@ public final class PlatformDefaults
public static void setLogicalPixelBase(int base)
{
if (LP_BASE != base) {
if (base < BASE_FONT_SIZE || base > BASE_SCALE_FACTOR)
if (base < BASE_FONT_SIZE || base > BASE_REAL_PIXEL)
throw new IllegalArgumentException("Unrecognized base: " + base);
LP_BASE = base;
......@@ -418,6 +479,27 @@ public final class PlatformDefaults
return BUTT_WIDTH;
}
public static void setMinimumButtonPadding(UnitValue padding)
{
BUTT_PADDING = padding;
MOD_COUNT++;
}
public static UnitValue getMinimumButtonPadding()
{
return BUTT_PADDING;
}
public static float getMinimumButtonWidthIncludingPadding(float refValue, ContainerWrapper parent, ComponentWrapper comp)
{
final int buttonMinWidth = getMinimumButtonWidth().getPixels(refValue, parent, comp);
if (comp != null && getMinimumButtonPadding() != null) {
return Math.max(comp.getMinimumWidth(comp.getWidth()) + getMinimumButtonPadding().getPixels(refValue, parent, comp) * 2, buttonMinWidth);
} else {
return buttonMinWidth;
}
}
/** Returns the unit value associated with the unit. (E.i. "related" or "indent"). Must be lower case.
* @param unit The unit string.
* @return The unit value associated with the unit. <code>null</code> for unrecognized units.
......@@ -444,7 +526,7 @@ public final class PlatformDefaults
* @param x The value for the horizontal dimension. If <code>null</code> the value is not changed.
* @param y The value for the vertical dimension. Might be same object as for <code>x</code>. If <code>null</code> the value is not changed.
*/
public static final void setUnitValue(String[] unitStrings, UnitValue x, UnitValue y)
public static void setUnitValue(String[] unitStrings, UnitValue x, UnitValue y)
{
for (String unitString : unitStrings) {
String s = unitString.toLowerCase().trim();
......@@ -476,7 +558,7 @@ public final class PlatformDefaults
/** Sets the order for the typical buttons in a standard button bar. It is one letter per button type.
* <p>
* Letter in upper case will get the minimum button width that the {@link #getMinimumButtonWidth()} specifies
* and letters in lower case will get the width the current look&feel specifies.
* and letters in lower case will get the width the current look&amp;feel specifies.
* <p>
* Gaps will never be added to before the first component or after the last component. However, '+' (push) will be
* applied before and after as well, but with a minimum size of 0 if first/last so there will not be a gap
......@@ -486,28 +568,28 @@ public final class PlatformDefaults
* <p>
* These are the characters that can be used:
* <ul>
* <li><code>'L'</code> - Buttons with this style tag will staticall end up on the left end of the bar.
* <li><code>'R'</code> - Buttons with this style tag will staticall end up on the right end of the bar.
* <li><code>'L'</code> - Buttons with this style tag will statically end up on the left end of the bar.
* <li><code>'R'</code> - Buttons with this style tag will statically end up on the right end of the bar.
* <li><code>'H'</code> - A tag for the "help" button that normally is supposed to be on the right.
* <li><code>'E'</code> - A tag for the "help2" button that normally is supposed to be on the left.
* <li><code>'Y'</code> - A tag for the "yes" button.
* <li><code>'N'</code> - A tag for the "no" button.
* <li><code>'X'</code> - A tag for the "next >" or "forward >" button.
* <li><code>'B'</code> - A tag for the "< back>" or "< previous" button.
* <li><code>'I'</code> - A tag for the "finish".
* <li><code>'X'</code> - A tag for the "next &gt;" or "forward &gt;" button.
* <li><code>'B'</code> - A tag for the "&lt; back" or "&lt; previous" button.
* <li><code>'I'</code> - A tag for the "finish" button.
* <li><code>'A'</code> - A tag for the "apply" button.
* <li><code>'C'</code> - A tag for the "cancel" or "close" button.
* <li><code>'O'</code> - A tag for the "ok" or "done" button.
* <li><code>'U'</code> - All Uncategorized, Other, or "Unknown" buttons. Tag will be "other".
* <li><code>'+'</code> - A glue push gap that will take as much space as it can and at least an "unrelated" gap. (Platform dependant)
* <li><code>'_'</code> - (underscore) An "unrelated" gap. (Platform dependant)
* <li><code>'+'</code> - A glue push gap that will take as much space as it can and at least an "unrelated" gap. (Platform dependent)
* <li><code>'_'</code> - (underscore) An "unrelated" gap. (Platform dependent)
* </ul>
* <p>
* Even though the style tags are normally applied to buttons this works with all components.
* <p>
* The normal style for MAC OS X is <code>"L_HE+U+FBI_NYCOA_R"</code>,
* for Windows is <code>"L_E+U+FBI_YNOCAH_R"</code>, and for GNOME is
* <code>"L_HE+UNYACBXIO_R"</code>.
* The normal style for MAC OS X is <code>"L_HE+U+NYBXCOA_I_R"</code>,
* for Windows is <code>"L_E+U+YNBXOCAH_I_R"</code>, and for GNOME is
* <code>"L_HE+UNYACBXO_I_R"</code>.
*
* @param order The new button order for the current platform.
*/
......@@ -571,9 +653,9 @@ public final class PlatformDefaults
return DEF_VGAP;
}
/** Returns the default dialog inset depending of the current platform.
/** Returns the default dialog insets depending of the current platform.
* @param side top == 0, left == 1, bottom = 2, right = 3.
* @return The inset. Never <code>null</code>.
* @return The insets. Never <code>null</code>.
*/
public static UnitValue getDialogInsets(int side)
{
......@@ -603,9 +685,9 @@ public final class PlatformDefaults
MOD_COUNT++;
}
/** Returns the default panel inset depending of the current platform.
/** Returns the default panel insets depending of the current platform.
* @param side top == 0, left == 1, bottom = 2, right = 3.
* @return The inset. Never <code>null</code>.
* @return The insets. Never <code>null</code>.
*/
public static UnitValue getPanelInsets(int side)
{
......@@ -646,8 +728,8 @@ public final class PlatformDefaults
/** Returns the default gap between two components that <b>are in the same cell</b>.
* @param comp The component that the gap is for. Never <code>null</code>.
* @param adjacentComp The adjacent component if any. May be <code>null</code>.
* @param adjacentSide What side the <code>adjacentComp</code> is on. {@link javax.swing.SwingUtilities#TOP} or
* {@link javax.swing.SwingUtilities#LEFT} or {@link javax.swing.SwingUtilities#BOTTOM} or {@link javax.swing.SwingUtilities#RIGHT}.
* @param adjacentSide What side the <code>adjacentComp</code> is on. {@link javax.swing.SwingUtilities#TOP} (1) or
* {@link javax.swing.SwingUtilities#LEFT} (2) or {@link javax.swing.SwingUtilities#BOTTOM} (3) or {@link javax.swing.SwingUtilities#RIGHT} (4).
* @param tag The tag string that the component might be tagged with in the component constraints. May be <code>null</code>.
* @param isLTR If it is left-to-right.
* @return The default gap between two components or <code>null</code> if there should be no gap.
......@@ -663,7 +745,8 @@ public final class PlatformDefaults
// if (adjacentComp == null || adjacentSide == SwingConstants.LEFT || adjacentSide == SwingConstants.TOP)
// return null;
return (adjacentSide == SwingConstants.LEFT || adjacentSide == SwingConstants.RIGHT) ? RELATED_X : RELATED_Y;
// SwingConstants.RIGHT == 4, SwingConstants.LEFT == 2
return (adjacentSide == 2 || adjacentSide == 4) ? RELATED_X : RELATED_Y;
}
/** Returns the current gap provider or <code>null</code> if none is set and "related" should always be used.
......
......@@ -40,10 +40,10 @@ import java.io.*;
*/
final class ResizeConstraint implements Externalizable
{
static final Float WEIGHT_100 = new Float(100);
static final Float WEIGHT_100 = 100f;
/** How flexilble the entity should be, relative to other entities, when it comes to growing. <code>null</code> or
* zero mean it will never grow. An entity that has twise the growWeight compared to another entity will get twice
/** How flexible the entity should be, relative to other entities, when it comes to growing. <code>null</code> or
* zero mean it will never grow. An entity that has twice the growWeight compared to another entity will get twice
* as much of available space.
* <p>
* "grow" are only compared within the same "growPrio".
......@@ -79,11 +79,13 @@ final class ResizeConstraint implements Externalizable
return LayoutUtil.getSerializedObject(this);
}
@Override
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
{
LayoutUtil.setSerializedObject(this, LayoutUtil.readAsXML(in));
}
@Override
public void writeExternal(ObjectOutput out) throws IOException
{
if (getClass() == ResizeConstraint.class)
......
File mode changed from 100644 to 100755