Examples of Picture


Examples of net.datacrow.core.objects.Picture

        try {
            image.setIDs();
            image.setValue(Image._A_TITLE, getName(filename, directoryUsage));
            image.setValue(Image._SYS_FILENAME, filename);
           
            Picture pic = (Picture) DcModules.get(DcModules._PICTURE).getItem();
            DcImageIcon icon;
            if (filename.toLowerCase().endsWith(".svg")) {
                SVGtoBufferedImageConverter converter = new SVGtoBufferedImageConverter();
                BufferedImage bi = converter.renderSVG(filename);
                icon = new DcImageIcon(Utilities.getScaledImage(new DcImageIcon(bi), 400, 400));
                filename = File.createTempFile(String.valueOf(Utilities.getUniqueID()), ".png").toString();
                icon.setFilename(filename);
                icon.save();
                bi.flush();
            } else {
                icon = new DcImageIcon(Utilities.getScaledImage(new DcImageIcon(filename), 400, 400));
                pic.setValue(Picture._G_EXTERNAL_FILENAME, filename);
            }
           
            int width = icon.getIconWidth();
            int height = icon.getIconHeight();
           
            image.setValue(Image._F_WIDTH, width != -1 ? Long.valueOf(width) : null);
            image.setValue(Image._G_HEIGHT, height != -1 ? Long.valueOf(height) : null);
           
            icon.getImage().flush();
           
            pic.setValue(Picture._A_OBJECTID, image.getID());
            pic.setValue(Picture._B_FIELD, image.getField(Image._I_IMAGE).getDatabaseFieldName());
            pic.setValue(Picture._D_IMAGE, icon);
            pic.isEdited(true);
           
            image.setValue(Image._I_IMAGE, pic);
           
            File jpegFile = new File(filename);
           
View Full Code Here

Examples of net.datacrow.core.objects.Picture

                // Make sure only changed fields are updated
                if (!dco.isChanged(field.getIndex()))
                    continue;
               
                if (field.getValueType() == DcRepository.ValueTypes._PICTURE) {
                    Picture picture = (Picture) dco.getValue(field.getIndex());
                    if (picture != null && (picture.isNew() || picture.isEdited() || picture.isDeleted())) {
                        picture.setValue(Picture._A_OBJECTID, dco.getID());
                        picture.setValue(Picture._B_FIELD, field.getDatabaseFieldName());
                        picture.setValue(Picture._C_FILENAME, dco.getID() + "_" + field.getDatabaseFieldName() + ".jpg");
                       
                        ImageIcon icon = (ImageIcon) picture.getValue(Picture._D_IMAGE);
                        if (icon != null) {
                            picture.setValue(Picture._E_HEIGHT, Long.valueOf(icon.getIconHeight()));
                            picture.setValue(Picture._F_WIDTH, Long.valueOf(icon.getIconWidth()));
                            pictures.add(picture);
                        }
                    }
                } else if (field.getValueType() == DcRepository.ValueTypes._DCOBJECTCOLLECTION) {
                    Collection<DcMapping> c = (Collection<DcMapping>) dco.getValue(field.getIndex());
                   
                    if (c != null) references.add(c);
                   
                    if (dco.isChanged(field.getIndex())) {
                        DcModule mappingMod = DcModules.get(DcModules.getMappingModIdx(field.getModule(), field.getReferenceIdx(), field.getIndex()));
                        String sql = "DELETE FROM " + mappingMod.getTableName() + " WHERE "
                                     mappingMod.getField(DcMapping._A_PARENT_ID).getDatabaseFieldName() + " = '" + dco.getID() + "'";
                        stmt.execute(sql);
                    }
                } else if (dco.isChanged(field.getIndex()) && !field.isUiOnly()) {
                    if (sbValues.length() > 0)
                        sbValues.append(", ");
   
                    sbValues.append(field.getDatabaseFieldName());
                    sbValues.append(" = ?");
                    values.add(getQueryValue(dco, field.getIndex()));
                }
            }
   
            String s = sbValues.toString();
            if (dco.getModule().getIndex() != DcModules._PICTURE && !Utilities.isEmpty(values)) {
                ps = conn.prepareStatement("UPDATE " + dco.getTableName() + " SET " + s + "\r\n WHERE ID = '" + dco.getID() + "'");
                setValues(ps, values);
                ps.execute();
                ps.close();
            } else if (!Utilities.isEmpty(values)) {
             
                ps = conn.prepareStatement("UPDATE " + dco.getTableName() + " SET " + s + "\r\n WHERE " +
                        dco.getDatabaseFieldName(Picture._A_OBJECTID) + " = '" + dco.getValue(Picture._A_OBJECTID) + "' AND " +
                        dco.getDatabaseFieldName(Picture._B_FIELD) + " = '" + dco.getValue(Picture._B_FIELD) + "'");
                setValues(ps, values);
                ps.execute();
                ps.close();
            }
   
            int counter = 0;
            for (Collection<DcMapping> c : references) {
               
                counter = 0;
                for (DcMapping mapping : c) {
                    stmt.execute("INSERT INTO " + mapping.getTableName() +
                                 " (" + mapping.getDatabaseFieldName(DcMapping._A_PARENT_ID) + ", " +
                                 mapping.getDatabaseFieldName(DcMapping._B_REFERENCED_ID) +
                                 ") \r\n VALUES ('" + dco.getID() + "', '" + mapping.getReferencedID() + "');");
                    counter++;
                }
            }
           
            for (Picture picture : pictures) {
                if (picture.isNew()) {
                    new InsertQuery(picture).run();
                    saveImage(picture);
                } else if (picture.isEdited()) {
                    new UpdateQuery(picture).run();
                    saveImage(picture);
                } else if (picture.isDeleted()) {
                    stmt.execute("DELETE FROM " + picture.getTableName() + " WHERE " +
                            picture.getField(Picture._A_OBJECTID).getDatabaseFieldName() + " = '" + dco.getID() + "' AND " +
                            picture.getField(Picture._B_FIELD).getDatabaseFieldName() + " = '" +  picture.getValue(Picture._B_FIELD) + "'");
                    deleteImage(picture);   
                }
            }
           
            for (DcObject child : dco.getCurrentChildren()) {
View Full Code Here

Examples of net.datacrow.core.objects.Picture

                String oldValue = Utilities.getComparableString(dcoOrig.getValue(fieldIdx));
                changed = !oldValue.equals(newValue);
                if (changed) logger.debug("Field " + field.getLabel() + " is changed. Old: " + oldValue + ". New: " + newValue);
            }
        } else if (field.getValueType() == DcRepository.ValueTypes._PICTURE) {
            Picture picture = (Picture) dcoOrig.getValue(fieldIdx);
            changed = (picture != null && (picture.isEdited() || picture.isNew() || picture.isDeleted())) ||
                      ((DcPictureField) component).isChanged();
           
            if (changed) logger.debug("Picture " + field.getLabel() + " is changed.");
        }
       
View Full Code Here

Examples of net.datacrow.core.objects.Picture

            loadImage();
    }
   
    private void loadImage() {
        int index = tabbedPane.getSelectedIndex() - 1;
        Picture picture = pictures.get(index);
        picture.loadImage(false);
       
        JPanel panel = imagePanels.get(index);
        Component[] components =  panel.getComponents();
        for (int i = 0; i < components.length; i++) {
            if (components[i] instanceof DcPictureField)
                ((DcPictureField) components[i]).setValue(picture.getValue(Picture._D_IMAGE));
        }
    }
View Full Code Here

Examples of net.datacrow.core.objects.Picture

   
    public void createImageTabs(DcObject dco) {
        try {
            clearImages();
   
            Picture picture;
            DcPictureField picField;
            JPanel panel;

            for (DcFieldDefinition definition : dco.getModule().getFieldDefinitions().getDefinitions()) {
                if (dco.isEnabled(definition.getIndex()) &&
                    dco.getField(definition.getIndex()).getValueType() == DcRepository.ValueTypes._PICTURE) {
                   
                    picture = (Picture) dco.getValue(definition.getIndex());

                    if (picture == null) continue;
                   
                    if (picture.hasImage()) {
                      pictures.add(picture);   

                      picField = ComponentFactory.getPictureField(true, false);
                      ComponentFactory.setBorder(this);
                       
View Full Code Here

Examples of net.datacrow.core.objects.Picture

               
                    String filename = dco.getDisplayString(index);
                    filename = filename.replaceAll(" ", "%20");
                    value = "<a " + Utilities.getHtmlStyle() + " href=\"file:///" + filename + "\">" + new File(dco.getDisplayString(index)).getName() + "</a>";                       
                } else if (dco.getField(index).getFieldType() == ComponentFactory._PICTUREFIELD) {
                  Picture p = (Picture) dco.getValue(index);
                  value = "<p><img src=\"file:///" + DataCrow.imageDir + "/" + p.getScaledFilename() + "\" alt=\"" + dco.getLabel(index) + "\"><p>";
                } else if (dco.getField(index).getFieldType() == ComponentFactory._URLFIELD) {
                  value = "<a " + Utilities.getHtmlStyle() + "  href=\"" +  dco.getValue(index) + "\">" + DcResources.getText("lblLink") + "</a>";
                } else if (dco.getField(index).getReferenceIdx() > 0 &&
                    dco.getField(index).getReferenceIdx() != dco.getModule().getIndex()) {
                   
                    if (dco.getField(index).getValueType() == DcRepository.ValueTypes._DCOBJECTCOLLECTION) {
                        int i = 0;
                       
                        List<DcObject> references = (List<DcObject>) dco.getValue(index);
                        for (DcObject reference : references) {
                            if (i > 0 && horizontal)
                                value += "&nbsp;&nbsp;";
                           
                            if (reference instanceof DcMapping)
                                reference = ((DcMapping) reference).getReferencedObject();
                           
                            if (reference == null)
                                continue;
                           
                            value += descriptionPane.createLink(reference, reference.toString());
                           
                            if (!horizontal)
                                value += "<br>";
                               
                            i++;
                        }
                    } else {
                        Object o = dco.getValue(index);
                        DcObject reference = o instanceof DcObject ? (DcObject) o : DataManager.getItem(dco.getField(index).getReferenceIdx(), (String) o);
                        reference = reference == null && o instanceof String ? DataManager.getObjectForString(dco.getField(index).getReferenceIdx(), (String) o) : reference;
                        value += descriptionPane.createLink(reference, reference.toString());
                    }
                } else { // Add simple value
                    value = dco.getDisplayString(index);
                   
                    if (dco.getField(index).getValueType() == DcRepository.ValueTypes._STRING) {
                        value = value.replaceAll("[\r\n]", "<br>");
                        value = value.replaceAll("[\t]", "    ");
                    }
                 
                    if (maxLength > 0)
                        value = StringUtils.concatUserFriendly(value, maxLength);
                   
                    if (font.getStyle() == Font.BOLD)
                        value = "<b>" + value + "</b>";
                   
                }
                   
                table += value;               
                table += "</td></tr>";
            } else if (dco.getField(index).getValueType() == DcRepository.ValueTypes._PICTURE) {
                Picture picture = (Picture) dco.getValue(index);
                pictures.add(picture);
            }
        }
       
        return table;
View Full Code Here

Examples of org.activiti.engine.identity.Picture

  public Picture getPicture() {
    if (pictureByteArrayId==null) {
      return null;
    }
    ByteArrayEntity pictureByteArray = getPictureByteArray();
    Picture picture = null;
    if (pictureByteArray != null) {
      picture = new Picture(pictureByteArray.getBytes(), pictureByteArray.getName());
    }
    return picture;
  }
View Full Code Here

Examples of org.apache.myfaces.tobago.example.addressbook.Picture

    return OUTCOME_LIST;
  }

  public String okFileUpload() {
    setRenderFileUploadPopup(false);
    Picture picture = new Picture(uploadedFile.getContentType(), uploadedFile.get());
    currentAddress.setPicture(picture);
    return null;
  }
View Full Code Here

Examples of org.apache.myfaces.tobago.example.addressbook.Picture

  public String invokeApplication(FacesContext facesContext) {
    Controller controller = (Controller) VariableResolverUtils.resolveVariable(facesContext, "controller");
    Address address = controller.getCurrentAddress();
    if (address.hasPicture()) {
      Picture picture = address.getPicture();
      byte[] content = picture.getContent();
      HttpServletResponse response = (HttpServletResponse) facesContext.getExternalContext().getResponse();
      if (content != null && content.length > 0) {
        response.setContentType(picture.getContentType());
        ByteArrayInputStream inputStream = new ByteArrayInputStream(content);
        try {
          IOUtils.copy(inputStream, response.getOutputStream());
        } catch (IOException e) {
          LOG.error("", e);
View Full Code Here

Examples of org.apache.myfaces.tobago.example.addressbook.Picture

  public String invokeApplication(FacesContext facesContext) {
    Controller controller = (Controller) VariableResolverUtils.resolveVariable(facesContext, "controller");
    Address address = controller.getCurrentAddress();
    if (address.hasPicture()) {
      Picture picture = address.getPicture();
      byte[] content = picture.getContent();
      HttpServletResponse response = (HttpServletResponse) facesContext.getExternalContext().getResponse();
      if (content != null && content.length > 0) {
        response.setContentType(picture.getContentType());
        ByteArrayInputStream inputStream = new ByteArrayInputStream(content);
        try {
          IOUtils.copy(inputStream, response.getOutputStream());
        } catch (IOException e) {
          LOG.error("", e);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.