Changeset 1064
- Timestamp:
- 05/15/16 17:34:37 (8 years ago)
- Location:
- trunk/src/org/expeditee/gui
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/expeditee/gui/FrameGraphics.java
r1055 r1064 65 65 66 66 // modes 67 p ublicstatic final int MODE_NORMAL = 0;68 69 p ublicstatic final int MODE_AUDIENCE = 1;70 71 p ublicstatic final int MODE_XRAY = 2;67 protected static final int MODE_NORMAL = 0; 68 69 protected static final int MODE_AUDIENCE = 1; 70 71 protected static final int MODE_XRAY = 2; 72 72 73 p ublicstatic final int MODE_AUDIENCE_FULLSCREEN = 4;73 protected static final int MODE_AUDIENCE_FULLSCREEN = 4; 74 74 75 75 … … 163 163 } 164 164 165 public static void forceXRayMode(boolean parse) { 166 setMode(MODE_XRAY,parse); 167 } 168 165 169 /** 166 170 * @return True if Audience Mode is currently on, False otherwise. … … 559 563 PaintLines(bg, lines); 560 564 } else { 561 // Don t paint the565 // Don't paint the 562 566 if (isActualFrame) 563 567 PaintLines(bg, freeItemsToPaint); … … 669 673 else { 670 674 if (DisplayIO.getCurrentSide() == 0) { 671 g.drawImage(left, 0, 0, Item.DEFAULT_BACKGROUND, null); 672 paintTransition(g,left); 675 if (!paintTransition(g,left)) { 676 // Nothing fancy occurred, just need to render the next slide to screen 677 g.drawImage(left, 0, 0, Item.DEFAULT_BACKGROUND, null); 678 } 673 679 } 674 680 else { 675 g.drawImage(right, 0, 0, Item.DEFAULT_BACKGROUND, null); 676 paintTransition(g,right); 681 if (!paintTransition(g,right)) { 682 // Nothing fancy occurred, just need to render the next slide to screen 683 g.drawImage(right, 0, 0, Item.DEFAULT_BACKGROUND, null); 684 } 677 685 } 678 686 } … … 681 689 682 690 683 private static voidpaintTransition(Graphics g, Image image)691 private static boolean paintTransition(Graphics g, Image image) 684 692 { 685 686 //If we are doing a transition 687 if(FrameTransitions.getSlide() == true){ 688 689 String input = "org.expeditee.gui.FrameTransitions"; 690 String slide_mode_method = FrameTransitions.getslideModeMethod(); 691 692 try { 693 Class<?> c = Class.forName(input); 694 695 Class[] cArg = new Class[3]; 696 cArg[0] = Graphics.class; 697 cArg[1] = Image.class; 698 cArg[2] = Dimension.class; 699 700 //Gets the method of transition and calls it 701 Method lMethod = c.getDeclaredMethod(slide_mode_method, cArg); 702 703 if(lMethod != null){ 704 // calling static method, so no class parameter needed 705 Object o = lMethod.invoke(null, g, image, _MaxSize); 706 } 707 else{ 708 System.err.println("Unable to locate the transition '" + slide_mode_method + "'"); 709 } 710 711 } catch (Exception e) { 712 713 System.err.println("An Reflection Exception occurred trying to invoke '" + slide_mode_method + "'"); 714 e.printStackTrace(); 715 } 716 } 717 //Tells the frame to only transition once 718 FrameTransitions.setSlideFalse(); 693 boolean performed_transition = false; 694 695 //If we are doing a transition 696 if(FrameTransitions.getSlide() == true){ 697 698 String input = "org.expeditee.gui.FrameTransitions"; 699 String slide_mode_method = FrameTransitions.getslideModeMethod(); 700 701 try { 702 Class<?> c = Class.forName(input); 703 704 Class[] cArg = new Class[3]; 705 cArg[0] = Graphics.class; 706 cArg[1] = Image.class; 707 cArg[2] = Dimension.class; 708 709 //Gets the method of transition and calls it 710 Method lMethod = c.getDeclaredMethod(slide_mode_method, cArg); 711 712 if(lMethod != null){ 713 // calling static method, so no class parameter needed 714 Object o = lMethod.invoke(null, g, image, _MaxSize); 715 performed_transition = true; 716 717 } 718 else{ 719 System.err.println("Unable to locate the transition '" + slide_mode_method + "'"); 720 } 721 722 } catch (Exception e) { 723 724 System.err.println("An Reflection Exception occurred trying to invoke '" + slide_mode_method + "'"); 725 e.printStackTrace(); 726 } 727 } 728 //Tells the frame to only transition once 729 FrameTransitions.setSlideFalse(); 730 731 return performed_transition; 719 732 } 720 733 -
trunk/src/org/expeditee/gui/FrameKeyboardActions.java
r1051 r1064 46 46 import org.expeditee.items.ItemUtils; 47 47 import org.expeditee.items.Line; 48 import org.expeditee.items.Picture; 48 49 import org.expeditee.items.Text; 49 50 import org.expeditee.items.UserAppliedPermission; … … 464 465 Item on = FrameUtils.getCurrentItem(); 465 466 466 if ( on == null){467 if ((on == null) || (on instanceof Picture)){ 467 468 navigateFrame(direction); 468 469 return; -
trunk/src/org/expeditee/gui/FrameMouseActions.java
r1047 r1064 1551 1551 } 1552 1552 1553 if (clicked instanceof Picture) { 1554 int mouseX = DisplayIO.getMouseX(); 1555 int mouseY = FrameMouseActions.getY(); 1556 Picture clickedOnPicture = (Picture)clicked; 1557 Frame current_frame = DisplayIO.getCurrentFrame(); 1558 Color bg_col = current_frame.getBackgroundColor(); 1559 if (clickedOnPicture.MouseOverBackgroundPixel(mouseX,mouseY,bg_col)) { 1560 // Make 'clicked' null, effectively causing a back() operation 1561 return false; 1562 } 1563 } 1564 1553 1565 return true; 1554 1566 } … … 1617 1629 } 1618 1630 // otherwise if the user is pointing at something, pick it up unless shift is down 1619 } else if (clicked != null && !isShiftDown) {1620 1621 // check permissions1622 if (!clicked.hasPermission(UserAppliedPermission.full)) {1623 Item editTarget = clicked.getEditTarget();1624 if (editTarget != clicked1625 && editTarget.hasPermission(UserAppliedPermission.full)) {1626 clicked = editTarget;1627 } else {1628 MessageBay1629 .displayMessage("Insufficient permission to pick up item");1630 return;1631 }1632 }1633 IndirectMouseActions.getInstance().getDetachLineAction().exec(new MouseInfo(clicked, clickedIn, false, false));1634 // if we're inside a shape, pick it up unless shift is down1635 } else if (clickedIn != null && !isShiftDown) {1636 IndirectMouseActions.getInstance().getGroupPickupAction().exec(new MouseInfo(clicked, clickedIn, false, false));1637 1631 } else { 1638 IndirectMouseActions.getInstance().getNewLineAction().exec(new MouseInfo(clicked, clickedIn, false, false)); 1632 if (clicked instanceof Picture) { 1633 int mouseX = DisplayIO.getMouseX(); 1634 int mouseY = FrameMouseActions.getY(); 1635 Picture clickedOnPicture = (Picture)clicked; 1636 Frame current_frame = DisplayIO.getCurrentFrame(); 1637 Color bg_col = current_frame.getBackgroundColor(); 1638 if (clickedOnPicture.MouseOverBackgroundPixel(mouseX,mouseY,bg_col)) { 1639 clicked = null; // Effectively make it as if they haven't clicked on anything 1640 } 1641 } 1642 if (clicked != null && !isShiftDown) { 1643 1644 // check permissions 1645 if (!clicked.hasPermission(UserAppliedPermission.full)) { 1646 Item editTarget = clicked.getEditTarget(); 1647 if (editTarget != clicked 1648 && editTarget.hasPermission(UserAppliedPermission.full)) { 1649 clicked = editTarget; 1650 } else { 1651 MessageBay 1652 .displayMessage("Insufficient permission to pick up item"); 1653 return; 1654 } 1655 } 1656 IndirectMouseActions.getInstance().getDetachLineAction().exec(new MouseInfo(clicked, clickedIn, false, false)); 1657 // if we're inside a shape, pick it up unless shift is down 1658 } else if (clickedIn != null && !isShiftDown) { 1659 IndirectMouseActions.getInstance().getGroupPickupAction().exec(new MouseInfo(clicked, clickedIn, false, false)); 1660 } else { 1661 IndirectMouseActions.getInstance().getNewLineAction().exec(new MouseInfo(clicked, clickedIn, false, false)); 1662 } 1639 1663 } 1640 1664 SessionStats.MovedItems(FreeItems.getInstance()); … … 1727 1751 return; 1728 1752 // if the user is clicking on something, merge the items 1729 // unless it is a point onto somethin other than a lineEnd or a1753 // unless it is a point onto something other than a lineEnd or a 1730 1754 // dot 1731 1755 } else if (clicked != null … … 1782 1806 } 1783 1807 } else { 1808 1809 if (clicked instanceof Picture) { 1810 int mouseX = DisplayIO.getMouseX(); 1811 int mouseY = FrameMouseActions.getY(); 1812 Picture clickedOnPicture = (Picture)clicked; 1813 Frame current_frame = DisplayIO.getCurrentFrame(); 1814 Color bg_col = current_frame.getBackgroundColor(); 1815 if (clickedOnPicture.MouseOverBackgroundPixel(mouseX,mouseY,bg_col)) { 1816 clicked = null; // Effectively make it as if they haven't clicked on anything 1817 } 1818 } 1819 1784 1820 // if the user is pointing at something and shift isn't down, make a copy 1785 1821 if (clicked != null && !isShiftDown()) { … … 2811 2847 Item start = l.getStartItem(); 2812 2848 2813 // If one end of a line is being del ted, remove the2849 // If one end of a line is being deleted, remove the 2814 2850 // other end if all its connecting lines are being 2815 // del ted2851 // deleted 2816 2852 if (items.contains(end)) { 2817 2853 if (!items.contains(start) … … 2848 2884 // this is a delete command 2849 2885 } else { 2886 2887 // Special case if toDelete item is an image: only want to delete if over non-background pixel color 2888 if (toDelete instanceof Picture) { 2889 int mouseX = DisplayIO.getMouseX(); 2890 int mouseY = FrameMouseActions.getY(); 2891 Picture clickedOnPicture = (Picture)toDelete; 2892 Frame current_frame = DisplayIO.getCurrentFrame(); 2893 Color bg_col = current_frame.getBackgroundColor(); 2894 if (clickedOnPicture.MouseOverBackgroundPixel(mouseX,mouseY,bg_col)) { 2895 // behave as if Redo/Undo request, then return 2896 if(isControlDown()) { 2897 DisplayIO.getCurrentFrame().redo(); 2898 } else { 2899 DisplayIO.getCurrentFrame().undo(); 2900 } 2901 return; 2902 } 2903 // If get to here, then user clicked on an image (non-trival pixel color), 2904 // so go ahead and let it be deleted in the usual way 2905 } 2906 2907 2850 2908 // check permissions 2851 2909 if (!toDelete.hasPermission(UserAppliedPermission.full)) { -
trunk/src/org/expeditee/gui/FrameTransitions.java
r980 r1064 9 9 import java.awt.Image; 10 10 import java.awt.RenderingHints; 11 import java.awt.image.BufferedImage; 12 import java.awt.image.ColorModel; 11 13 12 14 import org.expeditee.items.Item; … … 19 21 //Stores the frame before the new frame being transitioned to 20 22 private static Image _slideModeBaseImage = null; 21 23 private static Image _slideModeScratchImage = null; 24 22 25 //Tells graphics which method of transition is going to be used 23 26 private static String _slideModeMethod; … … 41 44 42 45 _slideModeBaseImage = i; 46 _slideModeScratchImage = new BufferedImage(i.getWidth(null), i.getHeight(null), BufferedImage.TYPE_INT_ARGB); 43 47 } 44 48 public static Image getSlideModeBaseImage(){ … … 146 150 Graphics2D g2d = (Graphics2D) g; 147 151 152 Graphics2D scratch_g2d = (Graphics2D)_slideModeScratchImage.getGraphics(); 153 148 154 while(alpha >= 0.1f){ 149 155 150 g.drawImage(FrameTransitions.getSlideModeBaseImage(), 0, 0, Item.DEFAULT_BACKGROUND, null); 151 g2d.setComposite(alphaCalcUp(alpha, fadeType)); 152 g2d.setColor(Color.WHITE); 153 g2d.fillRect(0, 0, d.width, d.height); 156 157 scratch_g2d.drawImage(getSlideModeBaseImage(), 0, 0, Item.DEFAULT_BACKGROUND, null); 158 scratch_g2d.setComposite(alphaCalcUp(alpha, fadeType)); 159 scratch_g2d.setColor(Color.WHITE); 160 scratch_g2d.fillRect(0, 0, d.width, d.height); 161 162 g2d.drawImage(_slideModeScratchImage, 0, 0, null); 163 154 164 alpha = alphaCalcUp(alpha, fadeType).getAlpha(); 155 165 … … 165 175 while(alpha <= 0.75f){ 166 176 167 g.drawImage(i, 0, 0, Item.DEFAULT_BACKGROUND, null); 168 g2d.setComposite(alphaCalcDown(alpha, fadeType)); 169 g2d.setColor(Color.WHITE); 170 g2d.fillRect(0, 0, d.width, d.height); 177 scratch_g2d.drawImage(i, 0, 0, Item.DEFAULT_BACKGROUND, null); 178 scratch_g2d.setComposite(alphaCalcDown(alpha, fadeType)); 179 scratch_g2d.setColor(Color.WHITE); 180 scratch_g2d.fillRect(0, 0, d.width, d.height); 181 182 g2d.drawImage(_slideModeScratchImage, 0, 0, null); 183 171 184 alpha = alphaCalcDown(alpha, fadeType).getAlpha(); 172 185 … … 181 194 } 182 195 } 196 183 197 //Calculates alpha values for transitions from transparent to opaque 184 198 //AlphaComposite is returned … … 220 234 } 221 235 } 236 237 public static void CrossFade(Graphics g, Image i, Dimension d) 238 { 239 // Based on: http://stackoverflow.com/questions/20346661/java-fade-in-and-out-of-images 240 // TODO: make use of timer, as this example does, rather than fixed delay 241 242 Image inImage = i; 243 Image outImage = _slideModeBaseImage; 244 int scratch_x_dim = _slideModeScratchImage.getWidth(null); 245 int scratch_y_dim = _slideModeScratchImage.getHeight(null); 246 247 int anim_timestep_msec = 10; 248 float alpha = 0.0f; 249 float alpha_inc = 0.04f; 250 251 Graphics2D g2d = (Graphics2D) g; 252 253 Graphics scratch_g = _slideModeScratchImage.getGraphics(); 254 255 while(alpha <= 1.0f){ 256 257 //scratch_g.clearRect(0, 0, scratch_x_dim, scratch_y_dim); 258 scratch_g.setColor(Color.WHITE); 259 scratch_g.fillRect(0, 0, scratch_x_dim, scratch_y_dim); 260 261 Graphics2D scratch_g2d = (Graphics2D) scratch_g.create(); 262 scratch_g2d.setComposite(AlphaComposite.SrcOver.derive(alpha)); 263 scratch_g2d.drawImage(inImage, 0, 0, null); 264 265 scratch_g2d.setComposite(AlphaComposite.SrcOver.derive(1f - alpha)); 266 scratch_g2d.drawImage(outImage, 0, 0, null); 267 scratch_g2d.dispose(); 268 269 g2d.drawImage(_slideModeScratchImage, 0, 0, null); 270 271 try { 272 Thread.sleep(anim_timestep_msec); 273 } catch (InterruptedException e) { 274 e.printStackTrace(); 275 } 276 277 alpha += alpha_inc; 278 } 279 } 280 281 222 282 } -
trunk/src/org/expeditee/gui/FrameUtils.java
r998 r1064 540 540 Parse(toDisplay); 541 541 542 // Test to see if frame transition required, and perform it if one if found 543 Item frameTransition = getAnnotation(toDisplay, "@frameTransition"); 544 if (frameTransition != null) { 545 doFrameTransition(frameTransition,current,toDisplay); 546 } 542 if (FrameGraphics.isAudienceMode()) { 543 // Only need to worry about frame transitions when in Audience Mode 547 544 545 // Test to see if frame transition specified through annotation, and perform it if one if found 546 Item frameTransition = getAnnotation(toDisplay, "@frameTransition"); 547 if (frameTransition != null) { 548 doFrameTransition(frameTransition,current,toDisplay); 549 } 550 } 551 548 552 DisplayIO.setCurrentFrame(toDisplay, incrementStats); 549 553 FrameMouseActions.updateCursor();
Note:
See TracChangeset
for help on using the changeset viewer.