From 917573abcbf8be523f622185f315afdc52362733 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guillaume=20T=C3=A2che?= Date: Fri, 6 Mar 2020 09:20:51 +0100 Subject: [PATCH] GH-65 Updates icons, removes LockIcon --- .../ri/common/views/annotations/LockIcon.java | 116 ------------------ .../annotations/PopupAnnotationComponent.java | 14 +-- .../org/icepdf/ri/images/lock_16.png | Bin 0 -> 397 bytes .../org/icepdf/ri/images/unlock_16.png | Bin 0 -> 528 bytes 4 files changed, 7 insertions(+), 123 deletions(-) delete mode 100644 viewer/viewer-awt/src/main/java/org/icepdf/ri/common/views/annotations/LockIcon.java create mode 100644 viewer/viewer-awt/src/main/resources/org/icepdf/ri/images/lock_16.png create mode 100644 viewer/viewer-awt/src/main/resources/org/icepdf/ri/images/unlock_16.png diff --git a/viewer/viewer-awt/src/main/java/org/icepdf/ri/common/views/annotations/LockIcon.java b/viewer/viewer-awt/src/main/java/org/icepdf/ri/common/views/annotations/LockIcon.java deleted file mode 100644 index 37384f420..000000000 --- a/viewer/viewer-awt/src/main/java/org/icepdf/ri/common/views/annotations/LockIcon.java +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Copyright 2006-2019 ICEsoft Technologies Canada Corp. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS - * IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either - * express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ -package org.icepdf.ri.common.views.annotations; - -import javax.swing.*; -import java.awt.*; -import java.awt.geom.GeneralPath; - -/** - * Vector based lock icon. - * - * @since 6.3 - */ -public class LockIcon implements Icon { - - protected static GeneralPath unlockedPath, lockedPath, unlockKeyPath, lockedKeyPath; - - - protected static double pathSize = 20; - protected static int width; - protected static int height; - - private Color backgroundColor; - private boolean isLock = true; - - public LockIcon(Color backgroundColor, Dimension dimension, boolean isLock) { - this.backgroundColor = backgroundColor; - this.isLock = isLock; - width = dimension.width; - height = dimension.height; - } - - public void setBackgroundColor(Color color) { - backgroundColor = backgroundColor; - } - - public void paintIcon(Component c, Graphics g, int x, int y) { - Graphics2D g2d = (Graphics2D) g.create(0, 0, c.getWidth(), c.getHeight()); - - g2d.setColor(backgroundColor); - - double scaledX = c.getWidth() / pathSize; - double scaledY = c.getHeight() / pathSize; - - g2d.scale(scaledX, scaledY); - g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); - g2d.setStroke(new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND)); - if (isLock) { - g2d.draw(lockedPath); - g2d.setStroke(new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND)); - g2d.draw(unlockKeyPath); - } else { - g2d.draw(unlockedPath); - g2d.setStroke(new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND)); - g2d.draw(lockedKeyPath); - } - g2d.dispose(); - } - - public int getIconWidth() { - return width; - } - - public int getIconHeight() { - return height; - } - - static { - - unlockedPath = new GeneralPath(); - unlockedPath.moveTo(4, 9); - unlockedPath.lineTo(15.5, 9); - unlockedPath.lineTo(15.5, 17); - unlockedPath.lineTo(4, 17); - unlockedPath.closePath(); - - unlockedPath.moveTo(5, 9); - unlockedPath.curveTo(5, 9, 5, 3, 9.75, 3); - unlockedPath.curveTo(9.75, 3, 14, 3, 14, 6); - - unlockKeyPath = new GeneralPath(); - unlockKeyPath.moveTo(9.5, 11); - unlockKeyPath.lineTo(9.5, 15); - - - lockedPath = new GeneralPath(); - lockedPath.moveTo(4, 9); - lockedPath.lineTo(15.5, 9); - lockedPath.lineTo(15.5, 17); - lockedPath.lineTo(4, 17); - lockedPath.closePath(); - - lockedPath.moveTo(5, 9); - lockedPath.curveTo(5, 9, 5, 3, 9.75, 3); - lockedPath.curveTo(9.75, 3, 14, 3, 14, 9); - - lockedKeyPath = new GeneralPath(); - lockedKeyPath.moveTo(8, 13); - lockedKeyPath.lineTo(11, 13); - - } - -} diff --git a/viewer/viewer-awt/src/main/java/org/icepdf/ri/common/views/annotations/PopupAnnotationComponent.java b/viewer/viewer-awt/src/main/java/org/icepdf/ri/common/views/annotations/PopupAnnotationComponent.java index 604c42158..9f2ef8d3a 100644 --- a/viewer/viewer-awt/src/main/java/org/icepdf/ri/common/views/annotations/PopupAnnotationComponent.java +++ b/viewer/viewer-awt/src/main/java/org/icepdf/ri/common/views/annotations/PopupAnnotationComponent.java @@ -28,6 +28,7 @@ import org.icepdf.ri.common.utility.annotation.properties.FreeTextAnnotationPanel; import org.icepdf.ri.common.views.*; import org.icepdf.ri.common.views.annotations.summary.AnnotationSummaryBox; +import org.icepdf.ri.images.Images; import javax.swing.*; import javax.swing.event.DocumentEvent; @@ -985,10 +986,6 @@ protected AnnotationComponent findAnnotationComponent(Annotation annotation) { return null; } - protected Icon createLockIcon(Color color, boolean isLock) { - return new LockIcon(color, BUTTON_SIZE, isLock); - } - protected void resetComponentColors() { Color contrastColor = calculateContrastHighLowColor(popupBackgroundColor.getRGB()); minimizeButton.setForeground(contrastColor); @@ -996,11 +993,14 @@ protected void resetComponentColors() { minimizeButton.setBackground(popupBackgroundColor); privateToggleButton.setBackground(popupBackgroundColor); // lock icons. - Icon lockedIcon = createLockIcon(contrastColor, true); - Icon unlockedIcon = createLockIcon(contrastColor, false); + Icon lockedIcon = new ImageIcon(Images.get("lock_16.png")); + Icon unlockedIcon = new ImageIcon(Images.get("unlock_16.png")); privateToggleButton.setIcon(unlockedIcon); - privateToggleButton.setPressedIcon(lockedIcon); + privateToggleButton.setPressedIcon(null); privateToggleButton.setSelectedIcon(lockedIcon); + privateToggleButton.setRolloverIcon(unlockedIcon); + privateToggleButton.setRolloverSelectedIcon(lockedIcon); + // text colors. titleLabel.setForeground(contrastColor); creationLabel.setForeground(contrastColor); diff --git a/viewer/viewer-awt/src/main/resources/org/icepdf/ri/images/lock_16.png b/viewer/viewer-awt/src/main/resources/org/icepdf/ri/images/lock_16.png new file mode 100644 index 0000000000000000000000000000000000000000..3cb7a11cb8f6a00677a435ffb2068856b3985ebd GIT binary patch literal 397 zcmV;80doF{P)(r)N`JCp7%ZHyoZ0pQZHx2Tw)7_ww)cE91yC6L&6hbo`A`= zDjyIQqhT2f87^)KgFO7|?&Y-lX>MSauo?AqAwe>9BBfK0FYJ@$)eqw#-r5L)JmNBd;Wtx+OhU~T%Z0YyyxKDDjGMzNb>dX7*2bq=~XTHzI)t*T|j rpLNYnQfu%oa&>0XUL=7#ls`7_2$*21{JNPH00000NkvXXu0mjfjuWSb literal 0 HcmV?d00001 diff --git a/viewer/viewer-awt/src/main/resources/org/icepdf/ri/images/unlock_16.png b/viewer/viewer-awt/src/main/resources/org/icepdf/ri/images/unlock_16.png new file mode 100644 index 0000000000000000000000000000000000000000..7562b261d37bbfc0850d0b81cbbab8ff15e5dc3f GIT binary patch literal 528 zcmV+r0`L8aP)1eTS_T$?d)xv7 zAWA+B&ZNfdc#y*PA{|MGZ*RA8H?xm{^;RNNL$m#+d$h{{FMtVYll9Rz!^VyWf3{q~ zvaO{juOIy(Um`XTsr5fk8epgyUxi`;=j^Beuu@+r=c*fls2`xCsX$$9uGRF7Oe29} zwp4PrvH&^$16Da#nb`lBP61y%`jH~S{^v9+ zFE=u^QthhA7?e^*wR}}eI9YWwxxM`SS-Q~F#)i-pO>#UD4MhE~I#ZE<7Xa{g`iS&~ zF;#sl0l|1b$nFkuf4Uc4HJ;mOtwlAE{Ia`vm?@kVJ!kch+l1W@2jmaW-~9&R+=q4; Sd}5mb00008N3 literal 0 HcmV?d00001