本文整理汇总了Java中com.codename1.ui.Component.LEFT属性的典型用法代码示例。如果您正苦于以下问题:Java Component.LEFT属性的具体用法?Java Component.LEFT怎么用?Java Component.LEFT使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.codename1.ui.Component
的用法示例。
在下文中一共展示了Component.LEFT属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getOppositeInset
/**
* Gets the opposite inset of this inset within its parent constraint. E.g. if this is the
* left inset, it will get the associated right inset.
* @return The opposite inset.
*/
public Inset getOppositeInset() {
LayeredLayoutConstraint cnst = LayeredLayoutConstraint.this;
if (cnst != null) {
int oppSide = 0;
switch (side) {
case Component.TOP:
oppSide = Component.BOTTOM;
break;
case Component.BOTTOM:
oppSide = Component.TOP;
break;
case Component.LEFT:
oppSide = Component.RIGHT;
break;
default:
oppSide = Component.LEFT;
}
return cnst.insets[oppSide];
}
return null;
}
示例2: getHorizAlign
/**
* Converts a textual horizontal alignment description to a Codename One alignment constant
*
* @param alignment The string describing the alignment
* @param defaultAlign The default alignment if the string cannot be converted
* @param allowJustify true to allow justify alignment, false to return center if justify is mentioned
* @return Component.LEFT, RIGHT or CENTER or the defaultAlign in case no match was found.
*/
private int getHorizAlign(String alignment,int defaultAlign,boolean allowJustify) {
if (alignment!=null) {
if (alignment.equals("left")) {
return Component.LEFT;
} else if (alignment.equals("right")) {
return Component.RIGHT;
} else if ((alignment.equals("center")) || (alignment.equals("middle"))) {
return Component.CENTER;
} else if (alignment.equals("justify")) {
return ((allowJustify) && (FIXED_WIDTH))?JUSTIFY:Component.CENTER;
}
}
return defaultAlign; //unknown alignment
}
示例3: reverseAlignForBidi
/**
* Reverses alignment in the case of bidi
*/
protected final int reverseAlignForBidi(boolean rtl, int align) {
if (rtl) {
switch (align) {
case Component.RIGHT:
return Component.LEFT;
case Component.LEFT:
return Component.RIGHT;
}
}
return align;
}
示例4: getLabelLinePos
private int getLabelLinePos(int align) {
int pos = 4;
if (align == Component.LEFT) {
pos = -pos;
}
return pos;
}
示例5: initAxesRangeForScale
public void initAxesRangeForScale(int i) {
mMinX[i] = MathHelper.NULL_VALUE;
mMaxX[i] = MathHelper.NULL_VALUE;
mMinY[i] = MathHelper.NULL_VALUE;
mMaxY[i] = MathHelper.NULL_VALUE;
double[] range = new double[] { mMinX[i], mMaxX[i], mMinY[i], mMaxY[i] };
initialRange.put(i, range);
mYTitle[i] = "";
mYTextLabels.put(i, new HashMap<Double, String>());
yLabelsAlign[i] = Component.CENTER;
yAxisAlign[i] = Component.LEFT;
}
示例6: getPreferredSize
/**
* {@inheritDoc}
*/
public Dimension getPreferredSize(Container parent) {
int maxWidth = 0;
int maxHeight = 0;
int numOfcomponents = parent.getComponentCount();
tmpLaidOut.clear();
for (int i = 0; i < numOfcomponents; i++) {
Component cmp = parent.getComponentAt(i);
calcPreferredValues(cmp);
LayeredLayoutConstraint constraint = (LayeredLayoutConstraint) getComponentConstraint(cmp);
int vInsets = 0;
int hInsets = 0;
if (constraint != null) {
vInsets += constraint.insets[Component.TOP].preferredValue
+ constraint.insets[Component.BOTTOM].preferredValue;
hInsets += constraint.insets[Component.LEFT].preferredValue
+ constraint.insets[Component.RIGHT].preferredValue;
}
maxHeight = Math.max(maxHeight, cmp.getPreferredH() + cmp.getStyle().getMarginTop() + cmp.getStyle().getMarginBottom() + vInsets);
maxWidth = Math.max(maxWidth, cmp.getPreferredW() + cmp.getStyle().getMarginLeftNoRTL() + cmp.getStyle().getMarginRightNoRTL() + hInsets);
}
Style s = parent.getStyle();
Dimension d = new Dimension(maxWidth + s.getPaddingLeftNoRTL() + s.getPaddingRightNoRTL(),
maxHeight + s.getPaddingTop() + s.getPaddingBottom());
if (preferredWidthMM > 0) {
int minW = Display.getInstance().convertToPixels(preferredWidthMM);
if (d.getWidth() < minW) {
d.setWidth(minW);
}
}
if (preferredHeightMM > 0) {
int minH = Display.getInstance().convertToPixels(preferredHeightMM);
if (d.getHeight() < Display.getInstance().convertToPixels(preferredHeightMM)) {
d.setHeight(minH);
}
}
return d;
}
示例7: toString
/**
* Prints this inset as a string.
* @return
*/
public String toString() {
switch (side) {
case Component.TOP : return "top="+getValueAsString();
case Component.BOTTOM: return "bottom="+getValueAsString();
case Component.LEFT: return "left="+getValueAsString();
default: return "right="+getValueAsString();
}
}
示例8: parseAlignment
static Integer parseAlignment(String alignment) {
if (Character.isDigit(alignment.charAt(0))) {
return Integer.parseInt(alignment);
} else if ("center".equalsIgnoreCase(alignment)) {
return Component.CENTER;
} else if ("left".equalsIgnoreCase(alignment)) {
return Component.LEFT;
} else if ("right".equalsIgnoreCase(alignment)) {
return Component.RIGHT;
}
return null;
}
示例9: getAlignmentString
private static String getAlignmentString(Integer alignment) {
if (alignment == null) {
return null;
}
switch (alignment) {
case Component.CENTER: return "center";
case Component.LEFT: return "left";
case Component.RIGHT: return "right";
}
return null;
}
示例10: getSpliceInsets
/**
* For a splicedImage border, this gets the spliced insets as a 4-element array of double values.
* @param out An out parameter. 4-element array of insets. Indices {@link Component#TOP}, {@link Component#BOTTOM}, {@link Component#LEFT}, and {@link Component#RIGHT}.
* @return 4-element array of insets. Indices {@link Component#TOP}, {@link Component#BOTTOM}, {@link Component#LEFT}, and {@link Component#RIGHT}.
*/
public double[] getSpliceInsets(double[] out) {
String[] parts = Util.split(BorderInfo.this.getSpliceInsets(), " ");
out[Component.TOP] = Double.parseDouble(parts[0]);
out[Component.RIGHT] = Double.parseDouble(parts[1]);
out[Component.BOTTOM] = Double.parseDouble(parts[2]);
out[Component.LEFT] = Double.parseDouble(parts[3]);
return out;
}
示例11: reverseAlignForBidi
/**
* Reverses alignment in the case of bidi
*/
private int reverseAlignForBidi(Component c, int align) {
if(c.isRTL()) {
switch(align) {
case Component.RIGHT:
return Component.LEFT;
case Component.LEFT:
return Component.RIGHT;
}
}
return align;
}
示例12: createCompoundBorder
/**
* Creates a border that is comprised of multiple border types so one border type can be used on top
* while another one can be used at the bottom. Notice that this doesn't work well with all border types (e.g. image borders)
* @param top the top border
* @param bottom the bottom border
* @param left the left border
* @param right the right border
* @return a compound border
*/
public static Border createCompoundBorder(Border top, Border bottom, Border left, Border right) {
if ((top != null && !top.isRectangleType()) ||
(bottom != null && !bottom.isRectangleType()) ||
(left != null && !left.isRectangleType()) ||
(right != null && !right.isRectangleType())) {
throw new IllegalArgumentException("Compound Border can be created "
+ "only from Rectangle types Borders");
}
if ((isSame(top, bottom)) && (isSame(top, left)) && (isSame(top, right))) {
return top; // Borders are all the same, returning one of them instead of creating a compound border which is more resource consuming
}
Border b = new Border();
b.type = TYPE_COMPOUND;
b.compoundBorders = new Border[4];
b.compoundBorders[Component.TOP] = top;
b.compoundBorders[Component.BOTTOM] = bottom;
b.compoundBorders[Component.LEFT] = left;
b.compoundBorders[Component.RIGHT] = right;
// Calculates the thickness of the entire border as the maximum of all 4 sides
b.thickness=0;
for(int i=Component.TOP;i<=Component.RIGHT;i++) {
if (b.compoundBorders[i]!=null) {
int sideThickness = (int)b.compoundBorders[i].thickness;
if (sideThickness>b.thickness) {
b.thickness=sideThickness;
}
}
}
return b;
}
示例13: calcBaseValue
/**
* Calculates the "base" value off of which the inset's value should be calculated.
*
* @param top The top "y" coordinate within the parent container from which insets are measured.
* @param left The left "x" coordinate within the parent container from which insets are measured.
* @param bottom The bottom "y" coordinate within the parent container from which insets are measured.
* @param right The right "x" coordinate within the parent container from which insets are measured.
* @return
*/
private int calcBaseValue(int top, int left, int bottom, int right) {//, int paddingTop, int paddingLeft, int paddingBottom, int paddingRight) {
int h = bottom - top;
int w = right - left;
int baseValue = 0;
if (referenceComponent != null) {
switch (side) {
case Component.TOP:
baseValue = getOuterY(referenceComponent) + (int)(getOuterHeight(referenceComponent) * referencePosition) - top;
break;
case Component.BOTTOM:
baseValue = (bottom - getOuterHeight(referenceComponent) - getOuterY(referenceComponent)) + (int)(getOuterHeight(referenceComponent) * referencePosition);
break;
case Component.LEFT:
baseValue = getOuterX(referenceComponent) + (int)(getOuterWidth(referenceComponent) * referencePosition) - left;
break;
default:
baseValue = (right - getOuterWidth(referenceComponent) - getOuterX(referenceComponent)) + (int)(getOuterWidth(referenceComponent)* referencePosition);
break;
}
calculatedBaseValue = baseValue;
return baseValue;
}
if (referencePosition != 0) {
switch (side) {
case Component.TOP:
baseValue = (int) ((float) h * referencePosition);
break;
case Component.BOTTOM:
baseValue = (int) ((float) h * referencePosition);
break;
case Component.LEFT:
baseValue = (int) ((float) w * referencePosition);
break;
case Component.RIGHT:
baseValue = (int) ((float) w * referencePosition);
break;
default:
throw new RuntimeException("Illegal side for inset: " + side);
}
}
calculatedBaseValue = baseValue;
return baseValue;
}
示例14: addLayoutComponent
/**
* {@inheritDoc}
*/
public void addLayoutComponent(Object name, Component comp, Container c) {
// helper check for a common mistake...
if (name == null) {
throw new IllegalArgumentException("Cannot add component to BorderLayout Container without constraint parameter");
}
// allows us to work with Component constraints too which makes some code simpler
if(name instanceof Integer) {
switch(((Integer)name).intValue()) {
case Component.TOP:
name = NORTH;
break;
case Component.BOTTOM:
name = SOUTH;
break;
case Component.LEFT:
name = WEST;
break;
case Component.RIGHT:
name = EAST;
break;
case Component.CENTER:
name = CENTER;
break;
default:
throw new IllegalArgumentException("BorderLayout Container expects one of the constraints BorderLayout.NORTH/SOUTH/EAST/WEST/CENTER");
}
}
Component previous = null;
/* Assign the component to one of the known regions of the layout.
*/
if (CENTER.equals(name)) {
previous = portraitCenter;
portraitCenter = comp;
} else if (NORTH.equals(name)) {
previous = portraitNorth;
portraitNorth = comp;
} else if (SOUTH.equals(name)) {
previous = portraitSouth;
portraitSouth = comp;
} else if (EAST.equals(name)) {
previous = portraitEast;
portraitEast = comp;
} else if (WEST.equals(name)) {
previous = portraitWest;
portraitWest = comp;
} else if (OVERLAY.equals(name)) {
previous = overlay;
overlay = comp;
} else {
throw new IllegalArgumentException("cannot add to layout: unknown constraint: " + name);
}
if (previous != null && previous != comp) {
c.removeComponent(previous);
}
}
示例15: left
/**
* Gets the left inset.
* @return The left inset
*/
public Inset left() {
return insets[Component.LEFT];
}