本文整理汇总了Java中com.codename1.ui.Component.getY方法的典型用法代码示例。如果您正苦于以下问题:Java Component.getY方法的具体用法?Java Component.getY怎么用?Java Component.getY使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.codename1.ui.Component
的用法示例。
在下文中一共展示了Component.getY方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: layoutContainer
import com.codename1.ui.Component; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
public void layoutContainer(Container parent) {
if(width < 0) {
return;
}
int numOfcomponents = parent.getComponentCount();
int parentW = parent.getWidth();
int parentH = parent.getHeight();
for(int i=0; i< numOfcomponents; i++){
Component cmp = parent.getComponentAt(i);
int x = cmp.getX() * parentW /width;
int y = cmp.getY() * parentH /height;
cmp.setX(x);
cmp.setY(y);
cmp.setWidth(cmp.getPreferredW());
cmp.setHeight(cmp.getPreferredH());
}
width = parentW;
height = parentH;
}
示例2: scrollToElement
import com.codename1.ui.Component; //导入方法依赖的package包/类
/**
* Scrolls the HTMLComponent to the specified element
*
* @param element The element to scroll to (must be contained in the document)
* @param animate true to animate the scrolling, false otherwise
* @throws IllegalArgumentException if the element is not contained in the current document.
*/
public void scrollToElement(HTMLElement element,boolean animate) {
if (!pageLoading()) {
if (!document.contains(element)) {
throw new IllegalArgumentException("The specified element is not contained in the current document.");
}
Vector v=element.getUi();
if ((v!=null) && (v.size()>0)) {
Component cmp=((Component)v.firstElement());
if (cmp!=null) {
Container parent=cmp.getParent();
int y=cmp.getY();
while ((parent!=null) && (parent!=this)) {
y+=parent.getY();
parent=parent.getParent();
}
scrollTo(y , animate);
}
}
} else {
throw new IllegalStateException("Page is still loading");
}
}
示例3: paintBorderBackground
import com.codename1.ui.Component; //导入方法依赖的package包/类
/**
* Has effect when the border demands responsibility for background painting
* normally the painter will perform this work but in this case the border might
* do it instead.
*
* @param g graphics context to draw onto
* @param c component whose border should be drawn
*/
public void paintBorderBackground(Graphics g, Component c) {
int x = c.getX();
int y = c.getY();
int width = c.getWidth();
int height = c.getHeight();
if (outerBorder != null) {
int ac;
if(millimeters) {
ac = Display.getInstance().convertToPixels(thickness);
} else {
ac = (int)thickness;
}
if (paintOuterBorderFirst) {
outerBorder.paintBorderBackground(g, c);
paintBorderBackground(g, x + ac, y + ac, width - ac * 2, height - ac * 2, c);
} else {
paintBorderBackground(g, x + ac, y + ac, width - ac * 2, height - ac * 2, c);
outerBorder.paintBorderBackground(g, c);
}
} else {
paintBorderBackground(g, x, y, width, height, c);
}
}
示例4: paint
import com.codename1.ui.Component; //导入方法依赖的package包/类
/**
* Draws the border for the given component, this method is called before a call to
* background painting is made.
*
* @param g graphics context to draw onto
* @param c component whose border should be drawn
*/
public void paint(Graphics g, Component c) {
int x = c.getX();
int y = c.getY();
int width = c.getWidth();
int height = c.getHeight();
if (outerBorder!=null) {
int ac;
if(millimeters) {
ac = Display.getInstance().convertToPixels(thickness);
} else {
ac = (int)thickness;
}
if(paintOuterBorderFirst) {
outerBorder.paint(g, x, y, width, height, c);
paint(g, x+ac, y+ac, width-ac*2, height-ac*2, c);
} else {
paint(g, x+ac, y+ac, width-ac*2, height-ac*2, c);
outerBorder.paint(g, x, y, width, height, c);
}
} else {
paint(g, x, y, width, height, c);
}
}
示例5: pointerReleasedImpl
import com.codename1.ui.Component; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
public void pointerReleasedImpl(int x, int y, boolean longPress) {
if (!isDragActivated()) {
// fire the action event into the selected component
Component cmp = renderer.getCellRendererComponent(ContainerList.this, model, model.getItemAt(offset), offset, hasFocus());
if(cmp instanceof Container) {
int absX = getAbsoluteX();
int absY = getAbsoluteY();
int newX = x - absX + cmp.getX();
int newY = y - absY + cmp.getY();
Component selectionCmp = ((Container) cmp).getComponentAt(newX, newY);
if(selectionCmp != null) {
selectionCmp.setX(0);
selectionCmp.setY(0);
if(longPress){
selectionCmp.longPointerPress(newX, newY);
fireActionEvent(new ActionEvent(ContainerList.this, x, y, true));
return;
}else{
selectionCmp.pointerPressed(newX, newY);
selectionCmp.pointerReleased(newX, newY);
}
}
}
fireActionEvent(new ActionEvent(ContainerList.this, x, y, longPress));
}
}
示例6: getOuterY
import com.codename1.ui.Component; //导入方法依赖的package包/类
private static int getOuterY(Component cmp) {
return cmp.getY() - cmp.getStyle().getMarginTop();
}