import edu.umd.cs.piccolo.nodes.PImage; //导入方法依赖的package包/类

public HorizontalTiledNode( double totalWidth, Image leftImage, Image centerImage, Image rightImage ) {

PImage leftNode = new PImage( leftImage );

PImage centerNode = new PImage( centerImage );

PImage rightNode = new PImage( rightImage );

if ( leftNode.getHeight() != centerNode.getHeight() || centerNode.getHeight() != rightNode.getHeight() ) {

throw new IllegalArgumentException( "all images must have the same height" );

}

// compute the number of tiles required to fill the center

double leftWidth = leftNode.getFullBoundsReference().getWidth();

double centerWidth = centerNode.getFullBoundsReference().getWidth();

double rightWidth = rightNode.getFullBoundsReference().getWidth();

if ( centerNode.getWidth() > ( leftWidth + rightWidth + ( 2 * X_OVERLAP ) ) ) {

throw new IllegalArgumentException( "center image is too wide, it will overlap other images" );

}

double tiledWidth = totalWidth - leftWidth - rightWidth;

// parent all nodes to this node, which will later be converted to an image

PNode parentNode = new PNode();

// left

parentNode.addChild( leftNode );

// right

parentNode.addChild( rightNode );

rightNode.setOffset( totalWidth - rightWidth, 0 );

// tile the center, with overlap between tiles to hide seams

PNode previousNode = leftNode;

while ( tiledWidth > 0 ) {

PImage tileNode = new PImage( centerImage );

parentNode.addChild( tileNode );

tileNode.setOffset( previousNode.getFullBoundsReference().getMaxX() - X_OVERLAP, 0 );

// If tile extends too far into right side, shift the tile to the left.

if ( tileNode.getFullBoundsReference().getMaxX() > rightNode.getFullBoundsReference().getMinX() + X_OVERLAP ) {

tileNode.setOffset( rightNode.getFullBoundsReference().getMinX() + X_OVERLAP - tileNode.getFullBoundsReference().getWidth(), 0 );

}

tiledWidth = tiledWidth - centerWidth + X_OVERLAP;

previousNode = tileNode;

}

// convert to image

setImage( parentNode.toImage() );

}

java中getHeight是什么意思_Java PImage.getHeight方法代码示例相关推荐

  1. java中getDelta是什么意思_Java IResourceDelta.getMarkerDeltas方法代码示例

    import org.eclipse.core.resources.IResourceDelta; //导入方法依赖的package包/类 public boolean visit(IResource ...

  2. java中peek是什么意思_Java Stack peek()方法与示例

    堆栈类peek()方法peek()方法在java.util包中可用. peek()方法用于从此Stack中返回顶部元素,并且它不删除就检索元素. peek()方法是一种非静态方法,只能通过类对象访问, ...

  3. java中skip是什么意思_Java PushbackReader skip()方法与示例

    PushbackReader类skip()方法skip()方法在java.io包中可用. skip()方法用于从此PushbackReader流中跳过给定数量的字符,它将阻塞直到存在某些字符输入或发生 ...

  4. java中skip是什么意思_Java LineNumberInputStream skip()方法与示例

    LineNumberInputStream类skip()方法skip()方法在java.io包中可用. skip()方法用于从此LineNumberInputStream流中跳过给定数目的数据字节. ...

  5. Java的阿尔法怎么打出来_Java FrameLayout.setAlpha方法代码示例

    import android.widget.FrameLayout; //导入方法依赖的package包/类 /** * コンストラクタ * * @param context Context */ T ...

  6. cdate在java中_Java Calendar.add方法代码示例

    本文整理汇总了Java中java.util.Calendar.add方法的典型用法代码示例.如果您正苦于以下问题:Java Calendar.add方法的具体用法?Java Calendar.add怎 ...

  7. java secretkey用法_Java SecretKeyFactory.generateSecret方法代码示例

    本文整理汇总了Java中javax.crypto.SecretKeyFactory.generateSecret方法的典型用法代码示例.如果您正苦于以下问题:Java SecretKeyFactory ...

  8. setcellvalue 格式_Java Cell.setCellValue方法代码示例

    本文整理汇总了Java中org.apache.poi.ss.usermodel.Cell.setCellValue方法的典型用法代码示例.如果您正苦于以下问题:Java Cell.setCellVal ...

  9. editable string 转_Java Editable.getSpans方法代码示例

    本文整理汇总了Java中android.text.Editable.getSpans方法的典型用法代码示例.如果您正苦于以下问题:Java Editable.getSpans方法的具体用法?Java ...

  10. python中uppercase是什么意思_Python string.uppercase方法代码示例

    本文整理汇总了Python中string.uppercase方法的典型用法代码示例.如果您正苦于以下问题:Python string.uppercase方法的具体用法?Python string.up ...

最新文章

  1. sql的不等于条件优化_SQL优化案例(2):OR条件优化
  2. centos php 局域网访问,CentOS8安装搭建php环境
  3. 人工智能将如何改进物联网?
  4. 开机后能解锁吗_黔隆科技刷机教程360奇酷Q5PLUS(1509A00)忘记密码刷机解锁降级救砖解屏幕锁账户锁教程...
  5. Python命名空间和作用域
  6. 自考计算机英语答题技巧,自考英语题型答题技巧-自考英语写作
  7. 8.Vue 事件处理
  8. 浅谈游戏自动寻路A*算法
  9. 在java 8 stream表达式中实现if/else逻辑
  10. mysql 分页优化策略(一)
  11. mybatis分页的一种解决方案
  12. blockquote 和 q 标签 css样式
  13. oracle 的控制结构
  14. 一种免费下载专利的方法
  15. 三、Oracle学习笔记:DDL数据定义语句
  16. python标准库math中用来计算平方根的函数是_Python程序设计的复习题资料合集免费下载...
  17. 批量部署windows和linux系统,使用Cobbler批量部署Linux和Windows:Windows系统批量安装(三)...
  18. 【标书应用场景】畅写Office为电子招投标提速赋能,助力项目招投标业务数字化转型
  19. JS 转换民族国标码(数字码和英文码)
  20. openwrt下部署adbyby去广告大师 免luci 带自启动,自动开启透明代理

热门文章

  1. Opencv实现图像无缝拼接,Sift查找特征点,Flann进行匹配
  2. flex align-center:center多行垂直方向居中 align-items:center垂直方向单行居中
  3. python 比较两文件夹的内容,具有通用性。
  4. jsp之jsp内置对象
  5. LinearLayout布局问题
  6. 智慧解析第20集:破解迷魂术
  7. 用HTML5的DOCTYPE标签兼容各版本IE浏览器的方法技术
  8. ORB_SLAM2之Pangolin的安装与问题处理
  9. matlab中的显示精度
  10. 如何写好一份专利交底书?