components/visual-panels/core/src/java/util/com/oracle/solaris/vp/util/swing/layout/ColumnLayoutConstraint.java
changeset 827 0944d8c0158b
equal deleted inserted replaced
826:c6aad84d2493 827:0944d8c0158b
       
     1 /*
       
     2  * CDDL HEADER START
       
     3  *
       
     4  * The contents of this file are subject to the terms of the
       
     5  * Common Development and Distribution License (the "License").
       
     6  * You may not use this file except in compliance with the License.
       
     7  *
       
     8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
       
     9  * or http://www.opensolaris.org/os/licensing.
       
    10  * See the License for the specific language governing permissions
       
    11  * and limitations under the License.
       
    12  *
       
    13  * When distributing Covered Code, include this CDDL HEADER in each
       
    14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
       
    15  * If applicable, add the following below this CDDL HEADER, with the
       
    16  * fields enclosed by brackets "[]" replaced with your own identifying
       
    17  * information: Portions Copyright [yyyy] [name of copyright owner]
       
    18  *
       
    19  * CDDL HEADER END
       
    20  */
       
    21 
       
    22 /*
       
    23  * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
       
    24  */
       
    25 
       
    26 package com.oracle.solaris.vp.util.swing.layout;
       
    27 
       
    28 public class ColumnLayoutConstraint extends
       
    29     AbstractTableConstraint<ColumnLayoutConstraint> implements HasAnchors {
       
    30 
       
    31     //
       
    32     // Static data
       
    33     //
       
    34 
       
    35     protected static final HorizontalAnchor DEFAULT_H_ANCHOR =
       
    36 	HorizontalAnchor.FILL;
       
    37 
       
    38     protected static final VerticalAnchor DEFAULT_V_ANCHOR =
       
    39 	VerticalAnchor.FILL;
       
    40 
       
    41     //
       
    42     // Instance data
       
    43     //
       
    44 
       
    45     private HorizontalAnchor hAnchor;
       
    46     private VerticalAnchor vAnchor;
       
    47 
       
    48     //
       
    49     // Constructors
       
    50     //
       
    51 
       
    52     public ColumnLayoutConstraint(HorizontalAnchor hAnchor,
       
    53 	VerticalAnchor vAnchor, int gap, float weight) {
       
    54 
       
    55 	super(gap, weight);
       
    56 	setHorizontalAnchor(hAnchor);
       
    57 	setVerticalAnchor(vAnchor);
       
    58     }
       
    59 
       
    60     public ColumnLayoutConstraint(
       
    61 	HorizontalAnchor hAnchor, int gap, float weight) {
       
    62 
       
    63 	this(hAnchor, DEFAULT_V_ANCHOR, gap, weight);
       
    64     }
       
    65 
       
    66     public ColumnLayoutConstraint(HorizontalAnchor hAnchor, int gap) {
       
    67 	this(hAnchor, gap, DEFAULT_WEIGHT);
       
    68     }
       
    69 
       
    70     public ColumnLayoutConstraint(HorizontalAnchor hAnchor) {
       
    71 	this(hAnchor, DEFAULT_GAP);
       
    72     }
       
    73 
       
    74     public ColumnLayoutConstraint() {
       
    75 	this(DEFAULT_H_ANCHOR);
       
    76     }
       
    77 
       
    78     //
       
    79     // Cloneable methods
       
    80     //
       
    81 
       
    82     @Override
       
    83     public ColumnLayoutConstraint clone() {
       
    84 	ColumnLayoutConstraint c = new ColumnLayoutConstraint();
       
    85 	cloneAttributes(c);
       
    86 	return c;
       
    87     }
       
    88 
       
    89     //
       
    90     // HasAnchors methods
       
    91     //
       
    92 
       
    93     @Override
       
    94     public HorizontalAnchor getHorizontalAnchor() {
       
    95 	return hAnchor;
       
    96     }
       
    97 
       
    98     @Override
       
    99     public VerticalAnchor getVerticalAnchor() {
       
   100 	return vAnchor;
       
   101     }
       
   102 
       
   103     //
       
   104     // AbstractTableConstraint methods
       
   105     //
       
   106 
       
   107     @Override
       
   108     public void cloneAttributes(AbstractTableConstraint constraint) {
       
   109 	super.cloneAttributes(constraint);
       
   110 	if (constraint instanceof ColumnLayoutConstraint) {
       
   111 	    ColumnLayoutConstraint c = (ColumnLayoutConstraint)constraint;
       
   112 	    c.setHorizontalAnchor(getHorizontalAnchor());
       
   113 	    c.setVerticalAnchor(getVerticalAnchor());
       
   114 	}
       
   115     }
       
   116 
       
   117     //
       
   118     // ColumnLayoutConstraint methods
       
   119     //
       
   120 
       
   121     public ColumnLayoutConstraint setHorizontalAnchor(
       
   122 	HorizontalAnchor hAnchor) {
       
   123 
       
   124 	this.hAnchor = hAnchor;
       
   125 	return this;
       
   126     }
       
   127 
       
   128     public ColumnLayoutConstraint setVerticalAnchor(VerticalAnchor vAnchor) {
       
   129 	this.vAnchor = vAnchor;
       
   130 	return this;
       
   131     }
       
   132 }