Ignore:
Timestamp:
12/03/19 15:29:07 (5 years ago)
Author:
bnemhaus
Message:

Added label existance check for when setting encryption label on a frame.

Added padlock icon on items that are encrypted.

Added key icon on items with KeyImage property set to 'PartialKey' or 'FullKey'. This will hopefully soon transformed into automatically setting these properties on key items that are on the secrets frame. The property should not be set-able by user once fully implemented and is only atm for debug purposes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/expeditee/items/Item.java

    r1466 r1477  
    4040import org.expeditee.core.Dimension;
    4141import org.expeditee.core.Fill;
     42import org.expeditee.core.Font;
    4243import org.expeditee.core.GradientFill;
    4344import org.expeditee.core.Point;
     
    4849import org.expeditee.core.bounds.PolygonBounds;
    4950import org.expeditee.encryption.core.EncryptedImage;
     51import org.expeditee.encryption.items.KeyType;
    5052import org.expeditee.encryption.items.surrogates.EncryptionDetail;
    5153import org.expeditee.encryption.items.surrogates.EncryptionDetail.Type;
     
    332334        protected Map<String, EncryptionDetail> primaryPropertyEncryption = new HashMap<String, EncryptionDetail>(primaryPropertyEncryptionDefault);
    333335        protected Map<String, Boolean> surrogatePropertyInheritance = new HashMap<String, Boolean>(surrogatePropertyInheritanceDefault);
     336
     337        private KeyType keyType = KeyType.NotAKey;
    334338       
    335339        {
     
    31163120        protected void paintLink() {
    31173121                paintLinkGraphic(getX() - LEFT_MARGIN, getY() + getLinkYOffset());
     3122                paintKeyGraphic(getX() - LEFT_MARGIN, getY() + getLinkYOffset());
     3123                paintPadlockGraphic(getX() - LEFT_MARGIN, getY() + getLinkYOffset());
    31183124        }
    31193125
     
    31753181                       
    31763182                        g.setAntialiasing(false);
     3183                }
     3184        }
     3185
     3186        protected void paintKeyGraphic(int x, int y) {
     3187                Colour fontColour = null;
     3188                switch (this.keyType()) {
     3189                case PartialKey:
     3190                        fontColour = Colour.LIGHT_GRAY;
     3191                        break;
     3192                case FullKey:
     3193                        fontColour = Colour.BLACK;
     3194                        break;
     3195                default:
     3196                        return;
     3197                }
     3198               
     3199                GraphicsManager g = EcosystemManager.getGraphicsManager();
     3200                g.setAntialiasing(true);
     3201                Font font = new Font();
     3202                g.drawString("\uD83D\uDD11", new Point(x,y), font, fontColour);
     3203                g.setAntialiasing(false);
     3204        }
     3205       
     3206        protected void paintPadlockGraphic(int x, int y) {
     3207                String encryptionLabel = this.getEncryptionLabel();
     3208                if (encryptionLabel != null && encryptionLabel.length() > 0) {
     3209                        GraphicsManager g = EcosystemManager.getGraphicsManager();
     3210                        g.setAntialiasing(true);
     3211                        Font font = new Font();
     3212                        g.drawString("\uD83D\uDD12", new Point(x,y), font, Colour.BLACK);
     3213                        g.setAntialiasing(false);
     3214                }
     3215        }
     3216       
     3217        public KeyType keyType() {
     3218                return keyType;
     3219        }
     3220       
     3221        public void setKeyType(String s) {
     3222                try {
     3223                        keyType = KeyType.valueOf(s);
     3224                } catch (IllegalArgumentException e) {
     3225                        keyType = KeyType.NotAKey;
    31773226                }
    31783227        }
Note: See TracChangeset for help on using the changeset viewer.