Changeset 607
- Timestamp:
- 12/12/13 10:08:13 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/expeditee/items/Picture.java
r603 r607 310 310 super.paintLink(g); 311 311 } 312 313 @Override 314 public void paint(Graphics2D g) { 315 if (_image == null) 312 313 public void paintImageTiling(Graphics2D g) { 314 if (_image == null) { 316 315 return; 317 316 } 317 318 318 int width = getWidth(); 319 319 int height = getHeight(); 320 321 paintLink(g);322 323 320 int dX1 = _source.getX(); 324 321 int dY1 = _source.getY(); 325 322 int dX2 = _source.getX() + width; 326 323 int dY2 = _source.getY() + height; 324 int iw = _image.getWidth(null); 325 int ih = _image.getHeight(null); 326 if(iw <= 0 || ih <= 0) { 327 return; 328 } 329 while(_start.x >= iw) { 330 _start.x -= iw; 331 _end.x -= iw; 332 } 333 while(_start.y >= ih) { 334 _start.y -= ih; 335 _end.y -= ih; 336 } 337 while(_start.x < 0) { 338 _start.x += iw; 339 _end.x += iw; 340 } 341 while(_start.y < 0) { 342 _start.y += ih; 343 _end.y += ih; 344 } 345 int cw = getUnscaledWidth(); 346 int ch = getUnscaledHeight(); 347 348 for(int x = dX1; x < dX2; x += cw) { 349 for(int y = dY1; y < dY2; y += ch) { 350 int endX = x + cw; 351 if(endX > dX2) { 352 endX = dX2; 353 } 354 int endY = y + ch; 355 if(endY > dY2) { 356 endY = dY2; 357 } 358 g.drawImage(_image, x, y, endX, endY, _start.x, _start.y, _end.x, 359 _end.y, _imageObserver); 360 } 361 } 362 } 363 364 @Override 365 public void paint(Graphics2D g) { 366 if (_image == null) 367 return; 368 369 paintLink(g); 327 370 328 371 // if we are showing the cropping, then show the original as transparent … … 332 375 g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 333 376 alpha)); 334 g.drawImage(_image, dX1, dY1, dX2, dY2, _start.x, _start.y, _end.x,335 _end.y, _imageObserver);377 378 paintImageTiling(g); 336 379 337 380 g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, … … 340 383 Point topLeft = getTopLeftCrop(); 341 384 Point bottomRight = getBottomRightCrop(); 342 Shape clip = new Rectangle( dX1 + topLeft.x, dY1+ topLeft.y,385 Shape clip = new Rectangle(_source.getX() + topLeft.x, _source.getY() + topLeft.y, 343 386 bottomRight.x - topLeft.x, bottomRight.y - topLeft.y); 344 387 g.setColor(getPaintHighlightColor()); … … 346 389 g.setClip(clip); 347 390 348 g.drawImage(_image, dX1, dY1, dX2, dY2, _start.x, _start.y, _end.x,349 _end.y, _imageObserver);391 paintImageTiling(g); 392 350 393 g.draw(clip); 351 394 // if the image is cropped, but we are not showing the cropping 352 395 // otherwise, paint normally 353 396 } else { 354 g.drawImage(_image, dX1, dY1, dX2, dY2, _start.x, _start.y, _end.x, 355 _end.y, _imageObserver); 397 paintImageTiling(g); 356 398 } 357 399
Note:
See TracChangeset
for help on using the changeset viewer.