jv.geom
Class PgTexture
- java.lang.Object
-
- jv.object.PsObject
-
- jv.geom.PgTexture
-
- All Implemented Interfaces:
- java.io.Serializable, java.lang.Cloneable, PsUpdateIf
public class PgTexture extends PsObject
Texture image associated to a geometry. The geometry must supply texture coordinates in [0,1]*[0,1], either at vertices or for elements. Texture coordinates outside the normalized texture square are mapped by modulo computation inside the domain.Repetition of texture image within the texture domain is possible in two ways: either texture coordinates of a geometry are scaled to rectangles [0,m]*[0,n], or alternatively by setting the repetition factors to m and n.
- See Also:
PgPointSet, Serialized Form- Author:
- Konrad Polthier
- Version:
- 01.06.07, 3.60 revised (kp) Default transparency mode changed to blend with surface material.
18.06.06, 3.50 revised (kp) Static variables for texture handling moved to PgGeometryIf.
04.06.06, 3.40 revised (kp) Repetition of texture image in horizontal and vertical direction implemented.
25.06.05, 3.30 revised (kp) Bug with pixel array removed which was not correctly updated on size changes.
15.03.05, 3.20 revised (kp) Keep texture as pixel array too to avoid multiple pix conversions.
21.02.04, 3.10 revised (kp) Clone and copy completed.
21.07.03, 3.00 revised (kp) Image bounds changed to PuInteger.
10.11.02, 2.40 revised (kp) Public method loadImage() added.
23.06.02, 2.30 revised (kp) Blending and filtering implemented.
22.03.02, 2.20 revised (ur) Internationalization.
08.07.01, 2.10 revised (kp) Bug in init() removed that size values were clipped at slider bounds.
27.06.01, 2.00 revised (kp) Full revision, cropping parameter added.
09.04.00, 1.10 revised (kp) File name added as instance variable.
00.00.98, 1.00 created (kp)
-
-
Field Summary
Fields Modifier and Type Field and Description static intBLEND_MATERIALDeprecated.since 3.96.022, use same instance variables of PgGeometryIf instead.static intBLEND_REPLACEDeprecated.since 3.96.022, use same instance variables of PgGeometryIf instead.static intFILTER_DIRECTDeprecated.since 3.96.022, use same instance variables of PgGeometryIf instead.static intFILTER_LINEARDeprecated.since 3.96.022, use same instance variables of PgGeometryIf instead.static intFILTER_QUADRATICDeprecated.since 3.96.022, use same instance variables of PgGeometryIf instead.-
Fields inherited from class jv.object.PsObject
HAS_BOUNDARY_PANEL, HAS_CONFIG_PANEL, HAS_INFO_PANEL, HAS_LABEL_PANEL, HAS_MATERIAL_PANEL, HAS_TEXTURE_PANEL, HAS_VECTOR_PANEL, INSPECTOR_INFO, INSPECTOR_INFO_EXT, IS_DELETED, IS_FIXED, IS_FOCUSSED, IS_PICKED, IS_SELECTED, IS_USED, NUM_TAGS
-
-
Constructor Summary
Constructors Constructor and Description PgTexture()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method and Description booleanblend(double s, PgTexture a, double t, PgTexture b)Blend between two texture objects usingthis = s*ag + t*bg.java.lang.Objectclone()Duplicate texture by recursively cloning all instance variables except inspector panels and lists of registered listeners.voidcopy(PgTexture tex)Copy base instance variables and prepend "Copy of" to name if identical to original object name.intgetBlendingMode()Get mode how texture color is applied to surface.intgetFilterType()Get mode how texture image is sampled to compute color of pixel.intgetHeight()Get height of used region in texture image.intgetHeightTiling()Get number of repetitions of texture image along height.java.awt.ImagegetImage()Get image of texture.java.lang.StringgetImageName()Get file name of texture image.intgetPeriodic()Get type of periodic extension of texture outside the unit texture square.int[]getPixels()Get pixel image of texture.PdVector[]getTextureImageBnd()Get bounds of texture image in normalized texture coordinates.intgetTextureSide()Determines whether texture is shown on front, back or both sides of a surface, if texture is shown at all.java.awt.DimensiongetTiling()Get number of repetitions of texture image in both directions.intgetUMax()Get upper width of used region in texture image.intgetUMin()Get lower width value of used region in texture image.intgetVMax()Get upper height of used region in texture image.intgetVMin()Get lower height value of used region in texture image.intgetWidth()Get width of used region in texture image.intgetWidthTiling()Get number of repetitions of texture image along width.voidinit()If instance has missing name then assign default name 'Object_NUMBER' where number is the total number of already created instances.booleanisEnabledMove()Get mode if size sliders are either used to resize the used sector of the texture image or to move the shown sector over the image.java.awt.ImageloadImage()Load image whose name was previously assigned to this class.java.awt.ImageloadImage(java.awt.Component comp)Load image whose name was previously assigned to this class.voidsetBlendingMode(int blendingMode)Set mode how texture color is applied to surface.voidsetEnabledMove(boolean flag)Set mode that size sliders are either used to resize the used sector of the texture image or to move the shown sector over the image.voidsetFilterType(int filterType)Set mode how texture image is sampled to compute color of pixel.voidsetImage(java.awt.Image image)Set image of texture.voidsetImage(java.lang.String name)Deprecated.use #setImageName(String) instead.voidsetImageName(java.lang.String name)Set file name of texture image including relative or full path or full url.voidsetPeriodic(int periodic)Set number of repetitions of texture image in both directions.voidsetTextureImageBnd(PdVector[] bnd)Set bounds of texture image in normalized texture coordinates.voidsetTextureSide(int side)Set flag whether texture is shown on front, back or both sides of a surface, if texture is shown at all.voidsetTiling(java.awt.Dimension repeat)Set number of repetitions of texture image in both directions.voidsetTiling(int width, int height)Set number of repetitions of texture image in both directions.voidsetUMax(int value)Set upper width of used region in texture image.voidsetUMin(int value)Set lower width value of used region in texture image.voidsetVMax(int value)Set upper height of used region in texture image.voidsetVMin(int value)Set lower height value of used region in texture image.booleanupdate(java.lang.Object event)Update the class whenever a child has changed.-
Methods inherited from class jv.object.PsObject
addInspector, addUpdateListener, assureInspector, clearTag, clone, clone, copy, getFather, getInfoPanel, getInspector, getName, getNumObjects, getSymbol, hasInspector, hasTag, hasUpdateListener, instanceOf, instanceOf, newInspector, newInspector, removeInspector, removeInspector, removeUpdateListener, setName, setParent, setSymbol, setTag, toString, updatePanels
-
-
-
-
Field Detail
-
FILTER_DIRECT
public static final int FILTER_DIRECT
Deprecated. since 3.96.022, use same instance variables of PgGeometryIf instead.No filtering, for each pixel the texture image is sampled at a single point.- See Also:
- Constant Field Values
-
FILTER_LINEAR
public static final int FILTER_LINEAR
Deprecated. since 3.96.022, use same instance variables of PgGeometryIf instead.Bilinear filtering, for each pixel the texture image is sampled at a four points.- See Also:
- Constant Field Values
-
FILTER_QUADRATIC
public static final int FILTER_QUADRATIC
Deprecated. since 3.96.022, use same instance variables of PgGeometryIf instead.Biquadratic filtering, for each pixel the texture image is sampled at a nine points.- See Also:
- Constant Field Values
-
BLEND_REPLACE
public static final int BLEND_REPLACE
Deprecated. since 3.96.022, use same instance variables of PgGeometryIf instead.Replace surface color with texture color.- See Also:
- Constant Field Values
-
BLEND_MATERIAL
public static final int BLEND_MATERIAL
Deprecated. since 3.96.022, use same instance variables of PgGeometryIf instead.Blends the surface color with texture color depending on texture alpha.- See Also:
- Constant Field Values
-
-
Method Detail
-
init
public void init()
Description copied from class:PsObjectIf instance has missing name then assign default name 'Object_NUMBER' where number is the total number of already created instances.
-
clone
public java.lang.Object clone()
Duplicate texture by recursively cloning all instance variables except inspector panels and lists of registered listeners. The parent relationship is maintained only within this class but not to external classes.Link to image is copied. Image is not cloned and not nulled since class Image has no clone() method.
- Overrides:
clonein classPsObject- See Also:
PsObject.copy(PsObject)- Version:
- 05.06.01, 1.10 revised (kp) Clone of PuInteger members.
21.10.00, 1.00 created (kp)
-
copy
public void copy(PgTexture tex)
Copy base instance variables and prepend "Copy of" to name if identical to original object name. In general, only geometry data is copied, no material properties and no external links.- See Also:
clone()- Version:
- 06.06.06, 1.10 revised (kp) Invalidate pixels if src texture has void pixels.
-
update
public boolean update(java.lang.Object event)
Update the class whenever a child has changed. Method is usually invoked from the children.- Specified by:
updatein interfacePsUpdateIf- Overrides:
updatein classPsObject- Parameters:
event- carries a lot of information- Returns:
- true if event has been handled, otherwise false
- See Also:
PsObject.setParent(PsUpdateIf),PsObject.getFather(),PsObject.addUpdateListener(PsUpdateIf)
-
getImageName
public java.lang.String getImageName()
Get file name of texture image.
-
setImageName
public void setImageName(java.lang.String name)
Set file name of texture image including relative or full path or full url.- Parameters:
name- name of image file including a relative path.
-
setImage
public void setImage(java.lang.String name)
Deprecated. use #setImageName(String) instead.Set file name of texture image including relative or full path or full url.
-
getImage
public java.awt.Image getImage()
Get image of texture.
-
setImage
public void setImage(java.awt.Image image)
Set image of texture. The cropping values are adjusted to cover the full image.
-
getPixels
public int[] getPixels()
Get pixel image of texture.
-
getTextureImageBnd
public PdVector[] getTextureImageBnd()
Get bounds of texture image in normalized texture coordinates.- Returns:
- array of length two with position of lower left and upper right position of image.
- Since:
- JavaView 2.86.000
- Version:
- 21.07.03, 1.00 created (kp)
-
setTextureImageBnd
public void setTextureImageBnd(PdVector[] bnd)
Set bounds of texture image in normalized texture coordinates. Bounds are given by two vectors with the position of lower left and upper right corner of the texture image in normalized texture coordinates. The dimension of each vector must be equal to the dimension of the texture. For a two-dimensional texture the default is {(0,0),(1,1)}.- Parameters:
bnd- array with bounds of image.- Since:
- JavaView 2.86.000
- Version:
- 21.07.03, 1.00 created (kp)
-
getUMin
public int getUMin()
Get lower width value of used region in texture image.- Returns:
- value in pixel coordinates
-
setUMin
public void setUMin(int value)
Set lower width value of used region in texture image.- Parameters:
value- in pixel coordinates
-
getVMin
public int getVMin()
Get lower height value of used region in texture image.- Returns:
- value in pixel coordinates
-
setVMin
public void setVMin(int value)
Set lower height value of used region in texture image.- Parameters:
value- in pixel coordinates
-
getUMax
public int getUMax()
Get upper width of used region in texture image.- Returns:
- value in pixel coordinates
-
setUMax
public void setUMax(int value)
Set upper width of used region in texture image.- Parameters:
value- in pixel coordinates
-
getVMax
public int getVMax()
Get upper height of used region in texture image.- Returns:
- value in pixel coordinates
-
setVMax
public void setVMax(int value)
Set upper height of used region in texture image.- Parameters:
value- in pixel coordinates
-
getWidth
public int getWidth()
Get width of used region in texture image.- Returns:
- value in pixel coordinates
-
getHeight
public int getHeight()
Get height of used region in texture image.- Returns:
- value in pixel coordinates
-
loadImage
public java.awt.Image loadImage()
Load image whose name was previously assigned to this class. The loaded image will become the image of this texture.Method is a convenience and simply calls
loadImage(PsConfig.getFrame()).- Returns:
- the loaded image, or
nullif failure.
-
loadImage
public java.awt.Image loadImage(java.awt.Component comp)
Load image whose name was previously assigned to this class. The loaded image will become the image of this texture.- Parameters:
comp- component to draw image on.- Returns:
- the loaded image, or
nullif failure.
-
getPeriodic
public int getPeriodic()
Get type of periodic extension of texture outside the unit texture square.- Returns:
- Type which is a value such as m_periodic.
- Since:
- JavaView 3.96.025
- Version:
- 22.06.06, 1.00 created (kp)
-
setPeriodic
public void setPeriodic(int periodic)
Set number of repetitions of texture image in both directions.- Parameters:
periodic- Type of periodic extension such as m_periodic.- Since:
- JavaView 3.96.025
- Version:
- 22.06.06, 1.00 created (kp)
-
getTiling
public java.awt.Dimension getTiling()
Get number of repetitions of texture image in both directions.- Returns:
- Number of repetitions of texture image in both directions.
-
setTiling
public void setTiling(java.awt.Dimension repeat)
Set number of repetitions of texture image in both directions.- Parameters:
repeat- Number of repetitions of texture image in both directions.
-
setTiling
public void setTiling(int width, int height)Set number of repetitions of texture image in both directions.- Parameters:
width- Number of repetitions of texture image along width.height- Number of repetitions of texture image along height.
-
getWidthTiling
public int getWidthTiling()
Get number of repetitions of texture image along width.- Returns:
- Number of repetitions of texture image along width.
-
getHeightTiling
public int getHeightTiling()
Get number of repetitions of texture image along height.- Returns:
- Number of repetitions of texture image along height.
-
getFilterType
public int getFilterType()
Get mode how texture image is sampled to compute color of pixel.- Returns:
- Filter type such as PgGeometryIf.FILTER_DIRECT, PgGeometryIf.FILTER_QUADRATIC ...
-
setFilterType
public void setFilterType(int filterType)
Set mode how texture image is sampled to compute color of pixel.- Parameters:
filterType- Filter type such as PgGeometryIf.FILTER_DIRECT, PgGeometryIf.FILTER_QUADRATIC ...
-
getBlendingMode
public int getBlendingMode()
Get mode how texture color is applied to surface.- Returns:
- Blending type such as PgGeometryIf.BLEND_REPLACE, PgGeometryIf.BLEND_MATERIAL ...
-
setBlendingMode
public void setBlendingMode(int blendingMode)
Set mode how texture color is applied to surface.- Parameters:
blendingMode- Blending type such as PgGeometryIf.BLEND_REPLACE, PgGeometryIf.BLEND_MATERIAL ...
-
getTextureSide
public int getTextureSide()
Determines whether texture is shown on front, back or both sides of a surface, if texture is shown at all.- Since:
- JavaView 3.96.022
- Version:
- 18.06.06, 1.00 created (kp)
-
setTextureSide
public void setTextureSide(int side)
Set flag whether texture is shown on front, back or both sides of a surface, if texture is shown at all.- Since:
- JavaView 3.96.022
- Version:
- 18.06.06, 1.00 created (kp)
-
isEnabledMove
public boolean isEnabledMove()
Get mode if size sliders are either used to resize the used sector of the texture image or to move the shown sector over the image.- Returns:
- Determines if size sliders are used to move rather than rescale image.
-
setEnabledMove
public void setEnabledMove(boolean flag)
Set mode that size sliders are either used to resize the used sector of the texture image or to move the shown sector over the image.- Parameters:
flag- Determines if size sliders are used to move rather than rescale image.
-
blend
public boolean blend(double s, PgTexture a, double t, PgTexture b)Blend between two texture objects usingthis = s*ag + t*bg. Image class is neither blended nor assigned, instead pixel values are blended.Images of both textures must have same dimensions. Otherwise an error is encountered and method returns.
- Parameters:
s- weight of first texturea- first texture used for blendingt- weight of second textureb- second texture used for blending- Returns:
- true on success
- Author:
- Konrad Polthier
- Version:
- 15.10.05, 1.00 created (kp)
-
-
"