001/* 002 * Renderer 4. The MIT License. 003 * Copyright (c) 2022 rlkraft@pnw.edu 004 * See LICENSE for details. 005*/ 006 007package renderer.scene.primitives; 008 009import java.util.List; 010 011/** 012 A {@code Point} object has two integers that represent the location 013 and color of a single {@link renderer.scene.Vertex}. The first integer 014 is an index into the {@link renderer.scene.Vertex} list of a 015 {@link renderer.scene.Model} object and the second integer is an index 016 into the {@link java.awt.Color} list of that {@link renderer.scene.Model} 017 object. 018*/ 019public class Point extends Primitive 020{ 021 public int radius = 0; 022 023 /** 024 Construct a {@code Point} object using an integer index. 025 Use the given index for both the {@link renderer.scene.Vertex} 026 and the {@link java.awt.Color} lists. 027 <p> 028 NOTE: This constructor does not put a {@link renderer.scene.Vertex} 029 or a {@link java.awt.Color} object into this {@link Primitive}'s 030 {@link renderer.scene.Model} object. This constructor assumes that 031 the given index is valid (or will be valid by the time this 032 {@link Primitive} gets rendered). 033 034 @param i index for the {@link renderer.scene.Vertex} and {@link java.awt.Color} of the new {@code Point} 035 */ 036 public Point(final int i) 037 { 038 this(i, i); 039 } 040 041 042 /** 043 Construct a {@code Point} object using two integer indices, one 044 for the {@link renderer.scene.Vertex} list and one for the 045 {@link java.awt.Color} list. 046 <p> 047 NOTE: This constructor does not put a {@link renderer.scene.Vertex} 048 or a {@link java.awt.Color} object into this {@link Primitive}'s 049 {@link renderer.scene.Model} object. This constructor assumes that 050 the given indices are valid (or will be valid by the time this 051 {@link Primitive} gets rendered). 052 053 @param v index for the {@link renderer.scene.Vertex} of the new {@code Point} 054 @param c index for the {@link java.awt.Color} of the new {@code Point} 055 */ 056 public Point(final int v, final int c) 057 { 058 super(); 059 060 vIndexList.add(v); 061 cIndexList.add(c); 062 } 063 064 065 /** 066 Construct a {@code Point} object using the two given 067 {@link List}s of integer indices. 068 <p> 069 NOTE: This constructor does not put any {@link renderer.scene.Vertex} 070 or {@link java.awt.Color} objects into this {@link Primitive}'s 071 {@link renderer.scene.Model} object. This constructor assumes that 072 the given indices are valid (or will be valid by the time this 073 {@link Primitive} gets rendered). 074 075 @param vIndexList {@link List} of integer indices into a {@link renderer.scene.Vertex} list 076 @param cIndexList {@link List} of integer indices into a {@link java.awt.Color} list 077 @throws NullPointerException if {@code vIndexList} is {@code null} 078 @throws NullPointerException if {@code cIndexList} is {@code null} 079 @throws IllegalArgumentException if the size of {@code vIndexList} or {@code cIndexList} is not 1 080 */ 081 public Point(final List<Integer> vIndexList, 082 final List<Integer> cIndexList) 083 { 084 super(vIndexList, cIndexList); 085 086 if ( 1 != vIndexList.size() ) 087 throw new IllegalArgumentException("the vertex index list must have length 1"); 088 if ( 1 != cIndexList.size() ) 089 throw new IllegalArgumentException("the color index list must have length 1"); 090 } 091 092 093 /** 094 For debugging. 095 096 @return {@link String} representation of this {@code Point} object 097 */ 098 @Override 099 public String toString() 100 { 101 return "Point: ([" + vIndexList.get(0) + "], " 102 + "[" + cIndexList.get(0) + "]) radius = " + radius; 103 } 104}