It will contain one FieldController object for each fields in the model.
*/
protected void initModelFields() {
modelFields.put( PHOTOGRAPHER, new FieldController( photos ) {
protected void setModelValue( Object model ) {
PhotoInfo obj = (PhotoInfo) model;
obj.setPhotographer( (String) value );
}
protected Object getModelValue( Object model ) {
if ( model == null ) {
return null;
}
PhotoInfo obj = (PhotoInfo) model;
return obj.getPhotographer();
}
protected void updateView( Object view ) {
PhotoInfoView obj = (PhotoInfoView) view;
obj.setPhotographer( (String) value );
}
protected void updateViewMultivalueState( Object view ) {
PhotoInfoView obj = (PhotoInfoView) view;
obj.setPhotographerMultivalued( isMultiValued );
}
protected void updateValue( Object view ) {
PhotoInfoView obj = (PhotoInfoView) view;
value = obj.getPhotographer();
}
});
modelFields.put( FUZZY_DATE, new FieldController( photos ) {
protected void setModelValue( Object model ) {
log.debug( "FUZZY_DATE - setModeValue ({}) " );
PhotoInfo obj = (PhotoInfo) model;
FuzzyDate fd = (FuzzyDate) value;
if ( fd != null ) {
obj.setShootTime( fd.getDate() );
obj.setTimeAccuracy( fd.getAccuracy() );
} else {
obj.setShootTime( null );
obj.setTimeAccuracy( 0 );
}
}
protected Object getModelValue( Object model ) {
log.debug( "FUZZY_DATE - getModeValue ({}) " );
PhotoInfo obj = (PhotoInfo) model;
Date date = obj.getShootTime();
double accuracy = obj.getTimeAccuracy();
return new FuzzyDate( date, accuracy );
}
protected void updateView( Object view ) {
log.debug( "FUZZY_DATE - updateView ({}) " );
PhotoInfoView obj = (PhotoInfoView) view;
obj.setFuzzyDate( (FuzzyDate) value );
}
protected void updateViewMultivalueState( Object view ) {
PhotoInfoView obj = (PhotoInfoView) view;
obj.setFuzzyDateMultivalued( isMultiValued );
}
protected void updateValue( Object view ) {
log.debug( "FUZZY_DATE - updateValue ({}) " );
PhotoInfoView obj = (PhotoInfoView) view;
value = obj.getFuzzyDate();
}
});
modelFields.put( QUALITY, new FieldController( photos ) {
protected void setModelValue( Object model ) {
PhotoInfo obj = (PhotoInfo) model;
if ( value != null ) {
obj.setQuality( ((Number)value).intValue() );
} else {
obj.setQuality( 0 );
}
}
protected Object getModelValue( Object model ) {
PhotoInfo obj = (PhotoInfo) model;
return new Double( obj.getQuality() );
}
protected void updateView( Object view ) {
PhotoInfoView obj = (PhotoInfoView) view;
obj.setQuality( (Number)value );
}
protected void updateViewMultivalueState( Object view ) {
PhotoInfoView obj = (PhotoInfoView) view;
obj.setQualityMultivalued( isMultiValued );
}
protected void updateValue( Object view ) {
PhotoInfoView obj = (PhotoInfoView) view;
value = obj.getQuality();
}
});
modelFields.put( SHOOTING_PLACE, new FieldController( photos ) {
protected void setModelValue( Object model ) {
PhotoInfo obj = (PhotoInfo) model;
obj.setShootingPlace( (String) value );
}
protected Object getModelValue( Object model ) {
PhotoInfo obj = (PhotoInfo) model;
return obj.getShootingPlace();
}
protected void updateView( Object view ) {
PhotoInfoView obj = (PhotoInfoView) view;
obj.setShootPlace( (String) value );
}
protected void updateViewMultivalueState( Object view ) {
PhotoInfoView obj = (PhotoInfoView) view;
obj.setShootPlaceMultivalued( isMultiValued );
}
protected void updateValue( Object view ) {
PhotoInfoView obj = (PhotoInfoView) view;
value = obj.getShootPlace();
}
});
modelFields.put( CAMERA_MODEL, new FieldController( photos ) {
protected void setModelValue( Object model ) {
PhotoInfo obj = (PhotoInfo) model;
obj.setCamera( (String) value );
}
protected Object getModelValue( Object model ) {
PhotoInfo obj = (PhotoInfo) model;
return obj.getCamera();
}
protected void updateView( Object view ) {
PhotoInfoView obj = (PhotoInfoView) view;
obj.setCamera( (String) value );
}
protected void updateViewMultivalueState( Object view ) {
PhotoInfoView obj = (PhotoInfoView) view;
obj.setCameraMultivalued( isMultiValued );
}
protected void updateValue( Object view ) {
PhotoInfoView obj = (PhotoInfoView) view;
value = obj.getCamera();
}
});
modelFields.put( FILM_TYPE, new FieldController( photos ) {
protected void setModelValue( Object model ) {
PhotoInfo obj = (PhotoInfo) model;
obj.setFilm( (String) value );
}
protected Object getModelValue( Object model ) {
PhotoInfo obj = (PhotoInfo) model;
return obj.getFilm();
}
protected void updateView( Object view ) {
PhotoInfoView obj = (PhotoInfoView) view;
obj.setFilm( (String) value );
}
protected void updateViewMultivalueState( Object view ) {
PhotoInfoView obj = (PhotoInfoView) view;
obj.setFilmMultivalued( isMultiValued );
}
protected void updateValue( Object view ) {
PhotoInfoView obj = (PhotoInfoView) view;
value = obj.getFilm();
}
});
modelFields.put( LENS_TYPE, new FieldController( photos ) {
protected void setModelValue( Object model ) {
PhotoInfo obj = (PhotoInfo) model;
obj.setLens( (String) value );
}
protected Object getModelValue( Object model ) {
PhotoInfo obj = (PhotoInfo) model;
return obj.getLens();
}
protected void updateView( Object view ) {
PhotoInfoView obj = (PhotoInfoView) view;
obj.setLens( (String) value );
}
protected void updateViewMultivalueState( Object view ) {
PhotoInfoView obj = (PhotoInfoView) view;
obj.setLensMultivalued( isMultiValued );
}
protected void updateValue( Object view ) {
PhotoInfoView obj = (PhotoInfoView) view;
value = obj.getLens();
}
});
modelFields.put( DESCRIPTION, new FieldController( photos ) {
protected void setModelValue( Object model ) {
PhotoInfo obj = (PhotoInfo) model;
obj.setDescription( (String) value );
}
protected Object getModelValue( Object model ) {
PhotoInfo obj = (PhotoInfo) model;
return obj.getDescription();
}
protected void updateView( Object view ) {
PhotoInfoView obj = (PhotoInfoView) view;
obj.setDescription( (String) value );
}
protected void updateViewMultivalueState( Object view ) {
PhotoInfoView obj = (PhotoInfoView) view;
obj.setDescriptionMultivalued( isMultiValued );
}
protected void updateValue( Object view ) {
PhotoInfoView obj = (PhotoInfoView) view;
value = obj.getDescription();
}
});
modelFields.put( TECHNOTE, new FieldController( photos ) {
protected void setModelValue( Object model ) {
PhotoInfo obj = (PhotoInfo) model;
obj.setTechNotes( (String) value );
}
protected Object getModelValue( Object model ) {
PhotoInfo obj = (PhotoInfo) model;
return obj.getTechNotes();
}
protected void updateView( Object view ) {
PhotoInfoView obj = (PhotoInfoView) view;
obj.setTechNote( (String) value );
}
protected void updateViewMultivalueState( Object view ) {
PhotoInfoView obj = (PhotoInfoView) view;
obj.setTechNoteMultivalued( isMultiValued );
}
protected void updateValue( Object view ) {
PhotoInfoView obj = (PhotoInfoView) view;
value = obj.getTechNote();
}
});
modelFields.put( F_STOP, new FieldController( photos ) {
protected void setModelValue( Object model ) {
PhotoInfo obj = (PhotoInfo) model;
if ( value != null ) {
obj.setFStop( ((Number)value).doubleValue() );
} else {
obj.setFStop( 0 );
}
}
protected Object getModelValue( Object model ) {
PhotoInfo obj = (PhotoInfo) model;
return new Double( obj.getFStop() );
}
protected void updateView( Object view ) {
PhotoInfoView obj = (PhotoInfoView) view;
obj.setFStop( (Number)value );
}
protected void updateViewMultivalueState( Object view ) {
PhotoInfoView obj = (PhotoInfoView) view;
obj.setFStopMultivalued( isMultiValued );
}
protected void updateValue( Object view ) {
PhotoInfoView obj = (PhotoInfoView) view;
value = obj.getFStop();
}
});
modelFields.put( SHUTTER_SPEED, new FieldController( photos ) {
protected void setModelValue( Object model ) {
PhotoInfo obj = (PhotoInfo) model;
if ( value != null ) {
obj.setShutterSpeed( ((Number)value).doubleValue() );
} else {
obj.setShutterSpeed( 0 );
}
}
protected Object getModelValue( Object model ) {
PhotoInfo obj = (PhotoInfo) model;
return new Double( obj.getShutterSpeed() );
}
protected void updateView( Object view ) {
PhotoInfoView obj = (PhotoInfoView) view;
obj.setShutterSpeed( (Number)value );
}
protected void updateViewMultivalueState( Object view ) {
PhotoInfoView obj = (PhotoInfoView) view;
obj.setShutterSpeedMultivalued( isMultiValued );
}
protected void updateValue( Object view ) {
PhotoInfoView obj = (PhotoInfoView) view;
value = obj.getShutterSpeed();
}
});
modelFields.put( FOCAL_LENGTH, new FieldController( photos ) {
protected void setModelValue( Object model ) {
PhotoInfo obj = (PhotoInfo) model;
if ( value != null ) {
obj.setFocalLength( ((Number)value).doubleValue() );
} else {
obj.setFocalLength( 0 );
}
}
protected Object getModelValue( Object model ) {
PhotoInfo obj = (PhotoInfo) model;
return new Double( obj.getFocalLength() );
}
protected void updateView( Object view ) {
PhotoInfoView obj = (PhotoInfoView) view;
obj.setFocalLength( (Number)value );
}
protected void updateViewMultivalueState( Object view ) {
PhotoInfoView obj = (PhotoInfoView) view;
obj.setFocalLengthMultivalued( isMultiValued );
}
protected void updateValue( Object view ) {
PhotoInfoView obj = (PhotoInfoView) view;
value = obj.getFocalLength();
}
});
modelFields.put( FILM_SPEED, new FieldController( photos ) {
protected void setModelValue( Object model ) {
PhotoInfo obj = (PhotoInfo) model;
if ( value != null ) {
obj.setFilmSpeed( ((Number)value).intValue() );
} else {
obj.setFilmSpeed( 0 );
}
}
protected Object getModelValue( Object model ) {
PhotoInfo obj = (PhotoInfo) model;
return new Double( obj.getFilmSpeed() );
}
protected void updateView( Object view ) {
PhotoInfoView obj = (PhotoInfoView) view;
obj.setFilmSpeed( (Number)value );
}
protected void updateViewMultivalueState( Object view ) {
PhotoInfoView obj = (PhotoInfoView) view;
obj.setFilmSpeedMultivalued( isMultiValued );
}
protected void updateValue( Object view ) {
PhotoInfoView obj = (PhotoInfoView) view;
value = obj.getFilmSpeed();
}
});
modelFields.put( RAW_SETTINGS, new FieldController( photos ) {
protected void setModelValue( Object model ) {
PhotoInfo obj = (PhotoInfo) model;
obj.setRawSettings( (RawConversionSettings) value );
}
protected Object getModelValue( Object model ) {
PhotoInfo obj = (PhotoInfo) model;
return obj.getRawSettings();
}
protected void updateView( Object view ) {
PhotoInfoView obj = (PhotoInfoView) view;
obj.setRawSettings( (RawConversionSettings) value );
}
protected void updateViewMultivalueState( Object view ) {
PhotoInfoView obj = (PhotoInfoView) view;
obj.setRawSettingsMultivalued( isMultiValued );
}
protected void updateValue( Object view ) {
PhotoInfoView obj = (PhotoInfoView) view;
value = obj.getRawSettings();
}
});
// Raw setting fields
modelFields.put( RAW_BLACK_LEVEL, new RawSettingFieldCtrl( photos, RAW_BLACK_LEVEL ) {
protected void doSetModelValue( RawSettingsFactory f, Object newValue ) {
if ( newValue != null ) {
f.setBlack( ((Number)value).intValue() );
} else {
f.setBlack( 0 );
}
}
protected Object doGetModelValue( RawConversionSettings r ) {
return new Integer( r.getBlack() );
}
protected void doSetViewValue( RawPhotoView view ) {
if ( value != null ) {
view.setRawBlack( ((Number)value).intValue() );
} else {
view.setRawBlack( 0 );
}
}
protected Object doGetViewValue( RawPhotoView view ) {
return new Integer( view.getRawBlack() );
}
protected void doSetViewMultivaluedState( RawPhotoView view ) {
view.setRawBlackMultivalued( isMultiValued, valueSet.toArray() );
}
});
modelFields.put( RAW_EV_CORR, new RawSettingFieldCtrl( photos, RAW_EV_CORR ) {
protected void doSetModelValue( RawSettingsFactory f, Object newValue ) {
if ( newValue != null ) {
f.setEvCorr( ((Number)value).doubleValue() );
} else {
f.setEvCorr( 0 );
}
}
protected Object doGetModelValue( RawConversionSettings r ) {
return new Double( r.getEvCorr() );
}
protected void doSetViewValue( RawPhotoView view ) {
if ( value != null ) {
view.setRawEvCorr( ((Number)value).doubleValue() );
} else {
view.setRawEvCorr( 0.0 );
}
}
protected Object doGetViewValue( RawPhotoView view ) {
return new Double( view.getRawEvCorr() );
}
protected void doSetViewMultivaluedState( RawPhotoView view ) {
view.setRawEvCorrMultivalued( this.isMultiValued, valueSet.toArray() );
}
});
modelFields.put( RAW_HLIGHT_COMP, new RawSettingFieldCtrl( photos, RAW_HLIGHT_COMP ) {
protected void doSetModelValue( RawSettingsFactory f, Object newValue ) {
if ( newValue != null ) {
f.setHlightComp( ((Number)value).doubleValue() );
} else {
f.setHlightComp( 0 );
}
}
protected Object doGetModelValue( RawConversionSettings r ) {
return new Double( r.getHighlightCompression() );
}
protected void doSetViewValue( RawPhotoView view ) {
if ( value != null ) {
view.setRawHlightComp( ((Number)value).doubleValue() );
} else {
view.setRawHlightComp( 0.0 );
}
}
protected Object doGetViewValue( RawPhotoView view ) {
return new Double( view.getRawHlightComp() );
}
protected void doSetViewMultivaluedState( RawPhotoView view ) {
view.setRawHlightCompMultivalued( this.isMultiValued, valueSet.toArray() );
}
});
modelFields.put( RAW_CTEMP, new RawSettingFieldCtrl( photos, RAW_CTEMP ) {
protected void doSetModelValue( RawSettingsFactory f, Object newValue ) {
if ( newValue != null ) {
f.setColorTemp( ((Number)value).doubleValue() );
} else {
f.setColorTemp( 0 );
}
}
protected Object doGetModelValue( RawConversionSettings r ) {
return new Double( r.getColorTemp() );
}
protected void doSetViewValue( RawPhotoView view ) {
if ( value != null ) {
view.setRawColorTemp( ((Number)value).doubleValue() );
} else {
view.setRawColorTemp( 0.0 );
}
}
protected Object doGetViewValue( RawPhotoView view ) {
return new Double( view.getRawColorTemp() );
}
protected void doSetViewMultivaluedState( RawPhotoView view ) {
view.setRawColorTempMultivalued( this.isMultiValued, valueSet.toArray() );
}
});
modelFields.put( RAW_GREEN, new RawSettingFieldCtrl( photos, RAW_GREEN ) {
protected void doSetModelValue( RawSettingsFactory f, Object newValue ) {
if ( newValue != null ) {
f.setGreenGain( ((Number)value).doubleValue() );
} else {
f.setGreenGain( 0 );
}
}
protected Object doGetModelValue( RawConversionSettings r ) {
return new Double( r.getGreenGain() );
}
protected void doSetViewValue( RawPhotoView view ) {
if ( value != null ) {
view.setRawGreenGain( ((Number)value).doubleValue() );
} else {
view.setRawGreenGain( 0.0 );
}
}
protected Object doGetViewValue( RawPhotoView view ) {
return new Double( view.getRawGreenGain() );
}
protected void doSetViewMultivaluedState( RawPhotoView view ) {
view.setRawGreenGainMultivalued( this.isMultiValued, valueSet.toArray() );
}
});
modelFields.put( RAW_COLOR_PROFILE, new RawSettingFieldCtrl( photos, RAW_COLOR_PROFILE ) {
protected void doSetModelValue( RawSettingsFactory f, Object newValue ) {
f.setColorProfile( (ColorProfileDesc) newValue );
}
protected Object doGetModelValue( RawConversionSettings r ) {
return r.getColorProfile();
}
protected void doSetViewValue( RawPhotoView view ) {
view.setRawProfile( (ColorProfileDesc) value );
}
protected Object doGetViewValue( RawPhotoView view ) {
return view.getRawProfile();
}
protected void doSetViewMultivaluedState( RawPhotoView view ) {
view.setRawProfileMultivalued( this.isMultiValued, valueSet.toArray() );
}
});
modelFields.put( COLOR_MAPPING, new FieldController( photos ) {
protected void setModelValue( Object model ) {
PhotoInfo obj = (PhotoInfo) model;
obj.setColorChannelMapping( (ChannelMapOperation) value );
}
protected Object getModelValue( Object model ) {
PhotoInfo obj = (PhotoInfo) model;
return obj.getColorChannelMapping();
}
protected void updateView( Object view ) {
PhotoInfoView obj = (PhotoInfoView) view;
obj.setColorChannelMapping( (ChannelMapOperation) value );
}
protected void updateViewMultivalueState( Object view ) {
PhotoInfoView obj = (PhotoInfoView) view;
obj.setColorChannelMappingMultivalued( isMultiValued );
}
protected void updateValue( Object view ) {
PhotoInfoView obj = (PhotoInfoView) view;
value = obj.getColorChannelMapping();
}
});
/*
TODO: Yes, this is a hack since preview image is not saved to model
at any point. Perhaps PhotoInofController should offer a generic
communication mechanism between views?
*/
modelFields.put( PREVIEW_IMAGE, new FieldController( photos ) {
protected void setModelValue( Object model ) {
// This is intended only as an information for other views
}
protected Object getModelValue( Object model ) {
return null;
}
protected void updateView( Object view ) {
if ( view instanceof PreviewImageView ) {
PreviewImageView obj = (PreviewImageView) view;
obj.modelPreviewImageChanged( (PhotovaultImage) value );
}
}
protected void updateViewMultivalueState( Object view ) {
// no implementation
}
protected void updateValue( Object view ) {
if ( view instanceof PreviewImageView ) {
PreviewImageView obj = (PreviewImageView) view;
value = obj.getPreviewImage();
} else {
value = null;
}
}
});