Databases.materials.types.Surface = Surface
! BULK_MATERIAL
-Databases.materials.Acrylic = Acrylic
-Databases.materials.Aluminum = Aluminum
-Databases.materials.Balsa = Balsa
-Databases.materials.Basswood = Basswood
-Databases.materials.Birch = Birch
-Databases.materials.Brass = Brass
-Databases.materials.Cardboard = Cardboard
-Databases.materials.Carbonfiber = Carbon fiber
-Databases.materials.Cork = Cork
-Databases.materials.DepronXPS = Depron (XPS)
-Databases.materials.Fiberglass = Fiberglass
-Databases.materials.Kraftphenolic = Kraft phenolic
-Databases.materials.Maple = Maple
-Databases.materials.Paperoffice = Paper (office)
-Databases.materials.Pine = Pine
-Databases.materials.Plywoodbirch = Plywood (birch)
-Databases.materials.PolycarbonateLexan = Polycarbonate (Lexan)
-Databases.materials.Polystyrene = Polystyrene
-Databases.materials.PVC = PVC
-Databases.materials.Spruce = Spruce
-Databases.materials.Steel = Steel
-Databases.materials.StyrofoamgenericEPS = Styrofoam (generic EPS)
-Databases.materials.StyrofoamBluefoamXPS = Styrofoam \"Blue foam\" (XPS)
-Databases.materials.Titanium = Titanium
-Databases.materials.Quantumtubing = Quantum tubing
-Databases.materials.BlueTube = Blue tube
+material.acrylic = Acrylic
+material.aluminum = Aluminum
+material.balsa = Balsa
+material.basswood = Basswood
+material.birch = Birch
+material.brass = Brass
+material.cardboard = Cardboard
+material.carbon_fiber = Carbon fiber
+material.cork = Cork
+material.depron_xps = Depron (XPS)
+material.fiberglass = Fiberglass
+material.kraft_phenolic = Kraft phenolic
+material.maple = Maple
+material.paper_office = Paper (office)
+material.pine = Pine
+material.plywood_birch = Plywood (birch)
+material.polycarbonate_lexan = Polycarbonate (Lexan)
+material.polystyrene = Polystyrene
+material.pvc = PVC
+material.spruce = Spruce
+material.steel = Steel
+material.styrofoam_generic_eps = Styrofoam (generic EPS)
+material.styrofoam_blue_foam_xps = Styrofoam \"Blue foam\" (XPS)
+material.titanium = Titanium
+material.quantum_tubing = Quantum tubing
+material.blue_tube = Blue tube
!SURFACE_MATERIAL
-Databases.materials.Ripstopnylon = Ripstop nylon
-Databases.materials.Mylar = Mylar
-Databases.materials.Polyethylenethin = Polyethylene (thin)
-Databases.materials.Polyethyleneheavy = Polyethylene (heavy)
-Databases.materials.Silk = Silk
-Databases.materials.Paperoffice = Paper (office)
-Databases.materials.Cellophane = Cellophane
-Databases.materials.Crepepaper = Cr\u00eape paper
+material.ripstop_nylon = Ripstop nylon
+material.mylar = Mylar
+material.polyethylene_thin = Polyethylene (thin)
+material.polyethylene_heavy = Polyethylene (heavy)
+material.silk = Silk
+material.paper_office = Paper (office)
+material.cellophane = Cellophane
+material.crepe_paper = Cr\u00eape paper
! LINE_MATERIAL
-Databases.materials.Threadheavy-duty = Thread (heavy-duty)
-Databases.materials.Elasticcordround2mm = Elastic cord (round 2mm, 1/16 in)
-Databases.materials.Elasticcordflat6mm = Elastic cord (flat 6mm, 1/4 in)
-Databases.materials.Elasticcordflat12mm = Elastic cord (flat 12mm, 1/2 in)
-Databases.materials.Elasticcordflat19mm = Elastic cord (flat 19mm, 3/4 in)
-Databases.materials.Elasticcordflat25mm = Elastic cord (flat 25mm, 1 in)
-Databases.materials.Braidednylon2mm = Braided nylon (2 mm, 1/16 in)
-Databases.materials.Braidednylon3mm = Braided nylon (3 mm, 1/8 in)
-Databases.materials.Tubularnylon11mm = Tubular nylon (11 mm, 7/16 in)
-Databases.materials.Tubularnylon14mm = Tubular nylon (14 mm, 9/16 in)
-Databases.materials.Tubularnylon25mm = Tubular nylon (25 mm, 1 in)
+material.thread_heavy_duty = Thread (heavy-duty)
+material.elastic_cord_round_2_mm_1_16_in = Elastic cord (round 2 mm, 1/16 in)
+material.elastic_cord_flat_6_mm_1_4_in = Elastic cord (flat 6 mm, 1/4 in)
+material.elastic_cord_flat_12_mm_1_2_in = Elastic cord (flat 12 mm, 1/2 in)
+material.elastic_cord_flat_19_mm_3_4_in = Elastic cord (flat 19 mm, 3/4 in)
+material.elastic_cord_flat_25_mm_1_in = Elastic cord (flat 25 mm, 1 in)
+material.braided_nylon_2_mm_1_16_in = Braided nylon (2 mm, 1/16 in)
+material.braided_nylon_3_mm_1_8_in = Braided nylon (3 mm, 1/8 in)
+material.tubular_nylon_11_mm_7_16_in = Tubular nylon (11 mm, 7/16 in)
+material.tubular_nylon_14_mm_9_16_in = Tubular nylon (14 mm, 9/16 in)
+material.tubular_nylon_25_mm_1_in = Tubular nylon (25 mm, 1 in)
! ExternalComponent
ExternalComponent.Rough = Rough
! Material database
! BULK_MATERIAL
-Databases.materials.Acrylic = Akryl
-Databases.materials.Aluminum = Hliník
-Databases.materials.Balsa = Balza
-Databases.materials.Basswood = Lípa
-Databases.materials.Birch = Bríza
-Databases.materials.Brass = Mosaz
-Databases.materials.Cardboard = Kartón
-Databases.materials.Carbonfiber = Vystu\u017Eený kartón
-Databases.materials.Cork = Korek
-Databases.materials.DepronXPS = Depron (XPS)
-Databases.materials.Fiberglass = Skelné vlákno
-Databases.materials.Kraftphenolic = Kraft phenolic
-Databases.materials.Maple = Javor
-Databases.materials.Paperoffice = Papír (kancelárský)
-Databases.materials.Pine = Borovice
-Databases.materials.Plywoodbirch = Prekli\u017Eka (briza)
-Databases.materials.PolycarbonateLexan = Polykarbonát (Lexan)
-Databases.materials.Polystyrene = Polystyrén
-Databases.materials.PVC = PVC
-Databases.materials.Spruce = Smrk
-Databases.materials.Steel = Ocel
-Databases.materials.StyrofoamgenericEPS = Styrofoam (obecný EPS)
-Databases.materials.StyrofoamBluefoamXPS = Styrofoam \"modrá pena\" (XPS)
-Databases.materials.Titanium = Titan
-Databases.materials.Quantumtubing = Quantum tubing
-Databases.materials.BlueTube = Blue tube
+material.acrylic = Akryl
+material.aluminum = Hliník
+material.balsa = Balza
+material.basswood = Lípa
+material.birch = Bríza
+material.brass = Mosaz
+material.cardboard = Kartón
+material.carbon_fiber = Vystu\u017Eený kartón
+material.cork = Korek
+material.depron_xps = Depron (XPS)
+material.fiberglass = Skelné vlákno
+material.kraft_phenolic = Kraft phenolic
+material.maple = Javor
+material.paper_office = Papír (kancelárský)
+material.pine = Borovice
+material.plywood_birch = Prekli\u017Eka (briza)
+material.polycarbonate_lexan = Polykarbonát (Lexan)
+material.polystyrene = Polystyrén
+material.pvc = PVC
+material.spruce = Smrk
+material.steel = Ocel
+material.styrofoam_generic_eps = Styrofoam (obecný EPS)
+material.styrofoam_blue_foam_xps = Styrofoam \"modrá pena\" (XPS)
+material.titanium = Titan
+material.quantum_tubing = Quantum tubing
+material.blue_tube = Blue tube
!SURFACE_MATERIAL
-Databases.materials.Ripstopnylon = Ripstoponový nylon
-Databases.materials.Mylar = Mylar
-Databases.materials.Polyethylenethin = Polyethylén (tenký)
-Databases.materials.Polyethyleneheavy = Polyethylén (te\u017Eký)
-Databases.materials.Silk = Hedvábí
-Databases.materials.Paperoffice = Papír (kancelárský)
-Databases.materials.Cellophane = Celofán
-Databases.materials.Crepepaper = Celulární papír
+material.ripstop_nylon = Ripstoponový nylon
+material.mylar = Mylar
+material.polyethylene_thin = Polyethylén (tenký)
+material.polyethylene_heavy = Polyethylén (te\u017Eký)
+material.silk = Hedvábí
+material.paper_office = Papír (kancelárský)
+material.cellophane = Celofán
+material.crepe_paper = Celulární papír
! LINE_MATERIAL
-Databases.materials.Threadheavy-duty = Vlákno (vysoce odolné)
-Databases.materials.Elasticcordround2mm = Elastická \u0161nura (round 2mm, 1/16 in)
-Databases.materials.Elasticcordflat6mm = Elastická \u0161nura (flat 6mm, 1/4 in)
-Databases.materials.Elasticcordflat12mm = Elastická \u0161nura (flat 12mm, 1/2 in)
-Databases.materials.Elasticcordflat19mm = Elastická \u0161nura (flat 19mm, 3/4 in)
-Databases.materials.Elasticcordflat25mm = Elastická \u0161nura (flat 25mm, 1 in)
-Databases.materials.Braidednylon2mm = Spletený nylon (2 mm, 1/16 in)
-Databases.materials.Braidednylon3mm = Spletený nylon (3 mm, 1/8 in)
-Databases.materials.Tubularnylon11mm = Trubkovitý nylon (11 mm, 7/16 in)
-Databases.materials.Tubularnylon14mm = Trubkovitý nylon (14 mm, 9/16 in)
-Databases.materials.Tubularnylon25mm = Trubkovitý nylon (25 mm, 1 in)
+material.thread_heavy_duty = Vlákno (vysoce odolné)
+material.elastic_cord_round_2_mm_1_16_in = Elastická \u0161nura (round 2mm, 1/16 in)
+material.elastic_cord_flat_6_mm_1_4_in = Elastická \u0161nura (flat 6mm, 1/4 in)
+material.elastic_cord_flat_12_mm_1_2_in = Elastická \u0161nura (flat 12mm, 1/2 in)
+material.elastic_cord_flat_19_mm_3_4_in = Elastická \u0161nura (flat 19mm, 3/4 in)
+material.elastic_cord_flat_25_mm_1_in = Elastická \u0161nura (flat 25mm, 1 in)
+material.braided_nylon_2_mm_1_16_in = Spletený nylon (2 mm, 1/16 in)
+material.braided_nylon_3_mm_1_8_in = Spletený nylon (3 mm, 1/8 in)
+material.tubular_nylon_11_mm_7_16_in = Trubkovitý nylon (11 mm, 7/16 in)
+material.tubular_nylon_14_mm_9_16_in = Trubkovitý nylon (14 mm, 9/16 in)
+material.tubular_nylon_25_mm_1_in = Trubkovitý nylon (25 mm, 1 in)
! ExternalComponent
ExternalComponent.Rough = drsný
\r
! Material database\r
! BULK_MATERIAL\r
-Databases.materials.Acrylic = Acryl\r
-Databases.materials.Aluminum = Aluminum\r
-Databases.materials.Balsa = Balsa\r
-Databases.materials.Basswood = Linde\r
-Databases.materials.Birch = Birke\r
-Databases.materials.Brass = Messing\r
-Databases.materials.Cardboard = Karton\r
-Databases.materials.Carbonfiber = Kohlefaser\r
-Databases.materials.Cork = Kork\r
-Databases.materials.DepronXPS = Depron (XPS)\r
-Databases.materials.Fiberglass = Glasfaser\r
-Databases.materials.Kraftphenolic = Pertinax\r
-Databases.materials.Maple = Ahorn\r
-Databases.materials.Paperoffice = Papier (Büro)\r
-Databases.materials.Pine = Kiefer\r
-Databases.materials.Plywoodbirch = Sperrholz (Birke)\r
-Databases.materials.PolycarbonateLexan = Polycarbonat (Lexan)\r
-Databases.materials.Polystyrene = Polystyrène\r
-Databases.materials.PVC = PVC\r
-Databases.materials.Spruce = Fichte\r
-Databases.materials.Steel = Stahl\r
-Databases.materials.StyrofoamgenericEPS = Styropor (EPS)\r
-Databases.materials.StyrofoamBluefoamXPS = Styrodur (XPS)\r
-Databases.materials.Titanium = Titan\r
-Databases.materials.Quantumtubing = Quantum-Röhren\r
-Databases.materials.BlueTube = 'Blue tube'-Röhren\r
+material.acrylic = Acryl\r
+material.aluminum = Aluminum\r
+material.balsa = Balsa\r
+material.basswood = Linde\r
+material.birch = Birke\r
+material.brass = Messing\r
+material.cardboard = Karton\r
+material.carbon_fiber = Kohlefaser\r
+material.cork = Kork\r
+material.depron_xps = Depron (XPS)\r
+material.fiberglass = Glasfaser\r
+material.kraft_phenolic = Pertinax\r
+material.maple = Ahorn\r
+material.paper_office = Papier (Büro)\r
+material.pine = Kiefer\r
+material.plywood_birch = Sperrholz (Birke)\r
+material.polycarbonate_lexan = Polycarbonat (Lexan)\r
+material.polystyrene = Polystyrène\r
+material.pvc = PVC\r
+material.spruce = Fichte\r
+material.steel = Stahl\r
+material.styrofoam_generic_eps = Styropor (EPS)\r
+material.styrofoam_blue_foam_xps = Styrodur (XPS)\r
+material.titanium = Titan\r
+material.quantum_tubing = Quantum-Röhren\r
+material.blue_tube = 'Blue tube'-Röhren\r
!SURFACE_MATERIAL\r
-Databases.materials.Ripstopnylon = Ripstop Nylon\r
-Databases.materials.Mylar = Mylar\r
-Databases.materials.Polyethylenethin = Polyethylen (dünn)\r
-Databases.materials.Polyethyleneheavy = Polyethylen (schwer)\r
-Databases.materials.Silk = Seide\r
-Databases.materials.Paperoffice = Papier (Büro)\r
-Databases.materials.Cellophane = Zellophan\r
-Databases.materials.Crepepaper = Krepppapier\r
+material.ripstop_nylon = Ripstop Nylon\r
+material.mylar = Mylar\r
+material.polyethylene_thin = Polyethylen (dünn)\r
+material.polyethylene_heavy = Polyethylen (schwer)\r
+material.silk = Seide\r
+material.paper_office = Papier (Büro)\r
+material.cellophane = Zellophan\r
+material.crepe_paper = Krepppapier\r
! LINE_MATERIAL\r
-Databases.materials.Threadheavy-duty = Faden (stark)\r
-Databases.materials.Elasticcordround2mm = Elastikband (rund, 2mm, 1/16 in)\r
-Databases.materials.Elasticcordflat6mm = Elastikband (flach, 6mm, 1/4 in)\r
-Databases.materials.Elasticcordflat12mm = Elastikband (flach, 12mm, 1/2 in)\r
-Databases.materials.Elasticcordflat19mm = Elastikband (flach, 19mm, 3/4 in)\r
-Databases.materials.Elasticcordflat25mm = Elastikband (flach, 25mm, 1 in)\r
-Databases.materials.Braidednylon2mm = Nylonflachband (2 mm, 1/16 in)\r
-Databases.materials.Braidednylon3mm = Nylonflachband (3 mm, 1/8 in)\r
-Databases.materials.Tubularnylon11mm = Tubular Nylon (11 mm, 7/16 in)\r
-Databases.materials.Tubularnylon14mm = Tubular Nylon (14 mm, 9/16 in)\r
-Databases.materials.Tubularnylon25mm = Tubular Nylon (25 mm, 1 in)\r
+material.thread_heavy_duty = Faden (stark)\r
+material.elastic_cord_round_2_mm_1_16_in = Elastikband (rund, 2mm, 1/16 in)\r
+material.elastic_cord_flat_6_mm_1_4_in = Elastikband (flach, 6mm, 1/4 in)\r
+material.elastic_cord_flat_12_mm_1_2_in = Elastikband (flach, 12mm, 1/2 in)\r
+material.elastic_cord_flat_19_mm_3_4_in = Elastikband (flach, 19mm, 3/4 in)\r
+material.elastic_cord_flat_25_mm_1_in = Elastikband (flach, 25mm, 1 in)\r
+material.braided_nylon_2_mm_1_16_in = Nylonflachband (2 mm, 1/16 in)\r
+material.braided_nylon_3_mm_1_8_in = Nylonflachband (3 mm, 1/8 in)\r
+material.tubular_nylon_11_mm_7_16_in = Tubular Nylon (11 mm, 7/16 in)\r
+material.tubular_nylon_14_mm_9_16_in = Tubular Nylon (14 mm, 9/16 in)\r
+material.tubular_nylon_25_mm_1_in = Tubular Nylon (25 mm, 1 in)\r
\r
! ExternalComponent\r
ExternalComponent.Rough = Rau\r
\r
! Material database\r
! BULK_MATERIAL\r
-Databases.materials.Acrylic = Acrílico\r
-Databases.materials.Aluminum = Aluminio\r
-Databases.materials.Balsa = Balsa\r
-Databases.materials.Basswood = Tilo\r
-Databases.materials.Birch = Abedul\r
-Databases.materials.Brass = Latón\r
-Databases.materials.Cardboard = Cartón\r
-Databases.materials.Carbonfiber = Fibra de Carbono\r
-Databases.materials.Cork = Corcho\r
-Databases.materials.DepronXPS = Depron (XPS)\r
-Databases.materials.Fiberglass = Fibra de vidrio\r
-Databases.materials.Kraftphenolic = Cartón fenólico\r
-Databases.materials.Maple = Arce\r
-Databases.materials.Paperoffice = Papel (oficina)\r
-Databases.materials.Pine = Pino\r
-Databases.materials.Plywoodbirch = Contrachapado\r
-Databases.materials.PolycarbonateLexan = Policarbonato (Lexan)\r
-Databases.materials.Polystyrene = Poliestireno\r
-Databases.materials.PVC = PVC\r
-Databases.materials.Spruce = Pícea (Abeto común)\r
-Databases.materials.Steel = Acero\r
-Databases.materials.StyrofoamgenericEPS = Porex (generico EPS)\r
-Databases.materials.StyrofoamBluefoamXPS = Porex \"Foam azul\" (XPS)\r
-Databases.materials.Titanium = Titanio\r
-Databases.materials.Quantumtubing = Quantum tubing\r
-Databases.materials.BlueTube = Tubo azul (PML)\r
+material.acrylic = Acrílico\r
+material.aluminum = Aluminio\r
+material.balsa = Balsa\r
+material.basswood = Tilo\r
+material.birch = Abedul\r
+material.brass = Latón\r
+material.cardboard = Cartón\r
+material.carbon_fiber = Fibra de Carbono\r
+material.cork = Corcho\r
+material.depron_xps = Depron (XPS)\r
+material.fiberglass = Fibra de vidrio\r
+material.kraft_phenolic = Cartón fenólico\r
+material.maple = Arce\r
+material.paper_office = Papel (oficina)\r
+material.pine = Pino\r
+material.plywood_birch = Contrachapado\r
+material.polycarbonate_lexan = Policarbonato (Lexan)\r
+material.polystyrene = Poliestireno\r
+material.pvc = PVC\r
+material.spruce = Pícea (Abeto común)\r
+material.steel = Acero\r
+material.styrofoam_generic_eps = Porex (generico EPS)\r
+material.styrofoam_blue_foam_xps = Porex \"Foam azul\" (XPS)\r
+material.titanium = Titanio\r
+material.quantum_tubing = Quantum tubing\r
+material.blue_tube = Tubo azul (PML)\r
!SURFACE_MATERIAL\r
-Databases.materials.Ripstopnylon = Ripstop nylon\r
-Databases.materials.Mylar = Mylar\r
-Databases.materials.Polyethylenethin = Polietileno (delgado)\r
-Databases.materials.Polyethyleneheavy = Polietileno (grueso)\r
-Databases.materials.Silk = Seda\r
-Databases.materials.Paperoffice = Papel (oficina)\r
-Databases.materials.Cellophane = Celofán\r
-Databases.materials.Crepepaper = Crespón de papel\r
+material.ripstop_nylon = Ripstop nylon\r
+material.mylar = Mylar\r
+material.polyethylene_thin = Polietileno (delgado)\r
+material.polyethylene_heavy = Polietileno (grueso)\r
+material.silk = Seda\r
+material.paper_office = Papel (oficina)\r
+material.cellophane = Celofán\r
+material.crepe_paper = Crespón de papel\r
! LINE_MATERIAL\r
-Databases.materials.Threadheavy-duty = Trenzado (Alta resistencia)\r
-Databases.materials.Elasticcordround2mm = Cordón elástico (aprox. 2mm, 1/16 in)\r
-Databases.materials.Elasticcordflat6mm = Cordón elástico plano (6mm, 1/4 in)\r
-Databases.materials.Elasticcordflat12mm = Cordón elástico plano (12mm, 1/2 in)\r
-Databases.materials.Elasticcordflat19mm = Cordón elástico plano (19mm, 3/4 in)\r
-Databases.materials.Elasticcordflat25mm = Cordón elástico plano (25mm, 1 in)\r
-Databases.materials.Braidednylon2mm = Nylon trenzado (2 mm, 1/16 in)\r
-Databases.materials.Braidednylon3mm = Nylon trenzado (3 mm, 1/8 in)\r
-Databases.materials.Tubularnylon11mm = Nylon tubular (11 mm, 7/16 in)\r
-Databases.materials.Tubularnylon14mm = Nylon tubular (14 mm, 9/16 in)\r
-Databases.materials.Tubularnylon25mm = Nylon tubular (25 mm, 1 in)\r
+material.thread_heavy_duty = Trenzado (Alta resistencia)\r
+material.elastic_cord_round_2_mm_1_16_in = Cordón elástico (aprox. 2mm, 1/16 in)\r
+material.elastic_cord_flat_6_mm_1_4_in = Cordón elástico plano (6mm, 1/4 in)\r
+material.elastic_cord_flat_12_mm_1_2_in = Cordón elástico plano (12mm, 1/2 in)\r
+material.elastic_cord_flat_19_mm_3_4_in = Cordón elástico plano (19mm, 3/4 in)\r
+material.elastic_cord_flat_25_mm_1_in = Cordón elástico plano (25mm, 1 in)\r
+material.braided_nylon_2_mm_1_16_in = Nylon trenzado (2 mm, 1/16 in)\r
+material.braided_nylon_3_mm_1_8_in = Nylon trenzado (3 mm, 1/8 in)\r
+material.tubular_nylon_11_mm_7_16_in = Nylon tubular (11 mm, 7/16 in)\r
+material.tubular_nylon_14_mm_9_16_in = Nylon tubular (14 mm, 9/16 in)\r
+material.tubular_nylon_25_mm_1_in = Nylon tubular (25 mm, 1 in)\r
\r
! ExternalComponent\r
ExternalComponent.Rough = Rugoso\r
Databases.materials.types.Surface = Surface\r
\r
! BULK_MATERIAL\r
-Databases.materials.Acrylic = Acrylique\r
-Databases.materials.Aluminum = Aluminum\r
-Databases.materials.Balsa = Balsa\r
-Databases.materials.Basswood = Tilleul\r
-Databases.materials.Birch = Bouleau\r
-Databases.materials.Brass = Laiton\r
-Databases.materials.Cardboard = Carton\r
-Databases.materials.Carbonfiber = Fibre de carbone\r
-Databases.materials.Cork = Liège\r
-Databases.materials.DepronXPS = Depron (XPS)\r
-Databases.materials.Fiberglass = Fibre de verre\r
-Databases.materials.Kraftphenolic = Kraft phénolique\r
-Databases.materials.Maple = Érable\r
-Databases.materials.Paperoffice = Papier (bureau)\r
-Databases.materials.Pine = Pin\r
-Databases.materials.Plywoodbirch = Contre-plaqué (bouleau)\r
-Databases.materials.PolycarbonateLexan = Polycarbonate (Lexan)\r
-Databases.materials.Polystyrene = Polystyrène\r
-Databases.materials.PVC = PVC\r
-Databases.materials.Spruce = Sapin\r
-Databases.materials.Steel = Acier\r
-Databases.materials.StyrofoamgenericEPS = Polystyrène (générique EPS)\r
-Databases.materials.StyrofoamBluefoamXPS = \"Mousse Bleue\" de polystyrène (XPS)\r
-Databases.materials.Titanium = Titane\r
-Databases.materials.Quantumtubing = Tube Quantum\r
-Databases.materials.BlueTube = Blue tube\r
+material.acrylic = Acrylique\r
+material.aluminum = Aluminum\r
+material.balsa = Balsa\r
+material.basswood = Tilleul\r
+material.birch = Bouleau\r
+material.brass = Laiton\r
+material.cardboard = Carton\r
+material.carbon_fiber = Fibre de carbone\r
+material.cork = Liège\r
+material.depron_xps = Depron (XPS)\r
+material.fiberglass = Fibre de verre\r
+material.kraft_phenolic = Kraft phénolique\r
+material.maple = Érable\r
+material.paper_office = Papier (bureau)\r
+material.pine = Pin\r
+material.plywood_birch = Contre-plaqué (bouleau)\r
+material.polycarbonate_lexan = Polycarbonate (Lexan)\r
+material.polystyrene = Polystyrène\r
+material.pvc = PVC\r
+material.spruce = Sapin\r
+material.steel = Acier\r
+material.styrofoam_generic_eps = Polystyrène (générique EPS)\r
+material.styrofoam_blue_foam_xps = \"Mousse Bleue\" de polystyrène (XPS)\r
+material.titanium = Titane\r
+material.quantum_tubing = Tube Quantum\r
+material.blue_tube = Blue tube\r
!SURFACE_MATERIAL\r
-Databases.materials.Ripstopnylon = Ripstop nylon\r
-Databases.materials.Mylar = Mylar\r
-Databases.materials.Polyethylenethin = Polyéthylène (fin)\r
-Databases.materials.Polyethyleneheavy = Polyéthylène (lourd)\r
-Databases.materials.Silk = Soie\r
-Databases.materials.Paperoffice = Papier (bureau)\r
-Databases.materials.Cellophane = Cellophane\r
-Databases.materials.Crepepaper = Papier crépon\r
+material.ripstop_nylon = Ripstop nylon\r
+material.mylar = Mylar\r
+material.polyethylene_thin = Polyéthylène (fin)\r
+material.polyethylene_heavy = Polyéthylène (lourd)\r
+material.silk = Soie\r
+material.paper_office = Papier (bureau)\r
+material.cellophane = Cellophane\r
+material.crepe_paper = Papier crépon\r
! LINE_MATERIAL\r
-Databases.materials.Threadheavy-duty = Fil(haute résistance)\r
-Databases.materials.Elasticcordround2mm = Corde Elastique (ronde 2mm, 1/16 in)\r
-Databases.materials.Elasticcordflat6mm = Corde Elastique (plate 6mm, 1/4 in)\r
-Databases.materials.Elasticcordflat12mm = Corde Elastique (plate 12mm, 1/2 in)\r
-Databases.materials.Elasticcordflat19mm = Corde Elastique (plate 19mm, 3/4 in)\r
-Databases.materials.Elasticcordflat25mm = Corde Elastique (plate 25mm, 1 in)\r
-Databases.materials.Braidednylon2mm = Nylon tressé (2 mm, 1/16 in)\r
-Databases.materials.Braidednylon3mm = Nylon tressé (3 mm, 1/8 in)\r
-Databases.materials.Tubularnylon11mm = Nylon tubulaire (11 mm, 7/16 in)\r
-Databases.materials.Tubularnylon14mm = Nylon tubulaire (14 mm, 9/16 in)\r
-Databases.materials.Tubularnylon25mm = Nylon tubulaire (25 mm, 1 in)\r
+material.thread_heavy_duty = Fil(haute résistance)\r
+material.elastic_cord_round_2_mm_1_16_in = Corde Elastique (ronde 2mm, 1/16 in)\r
+material.elastic_cord_flat_6_mm_1_4_in = Corde Elastique (plate 6mm, 1/4 in)\r
+material.elastic_cord_flat_12_mm_1_2_in = Corde Elastique (plate 12mm, 1/2 in)\r
+material.elastic_cord_flat_19_mm_3_4_in = Corde Elastique (plate 19mm, 3/4 in)\r
+material.elastic_cord_flat_25_mm_1_in = Corde Elastique (plate 25mm, 1 in)\r
+material.braided_nylon_2_mm_1_16_in = Nylon tressé (2 mm, 1/16 in)\r
+material.braided_nylon_3_mm_1_8_in = Nylon tressé (3 mm, 1/8 in)\r
+material.tubular_nylon_11_mm_7_16_in = Nylon tubulaire (11 mm, 7/16 in)\r
+material.tubular_nylon_14_mm_9_16_in = Nylon tubulaire (14 mm, 9/16 in)\r
+material.tubular_nylon_25_mm_1_in = Nylon tubulaire (25 mm, 1 in)\r
\r
! ExternalComponent\r
ExternalComponent.Rough = Rugueuse\r
! Material database
! BULK_MATERIAL
-Databases.materials.Acrylic = Acrilico
-Databases.materials.Aluminum = Aluminum
-Databases.materials.Balsa = Balsa
-Databases.materials.Basswood = Basswood
-Databases.materials.Birch = Betulla
-Databases.materials.Brass = Brass
-Databases.materials.Cardboard = Cartoncino
-Databases.materials.Carbonfiber = Fibra di carbonio
-Databases.materials.Cork = Sughero
-Databases.materials.DepronXPS = Depron (XPS)
-Databases.materials.Fiberglass = Fibra di vetro
-Databases.materials.Kraftphenolic = Kraft phenolic
-Databases.materials.Maple = Acero
-Databases.materials.Paperoffice = Carta (ufficio)
-Databases.materials.Pine = Pino
-Databases.materials.Plywoodbirch = Compensato (betulla)
-Databases.materials.PolycarbonateLexan = Policarbonato (Lexan)
-Databases.materials.Polystyrene = Polistirene
-Databases.materials.PVC = PVC
-Databases.materials.Spruce = Abete rosso
-Databases.materials.Steel = Steel
-Databases.materials.StyrofoamgenericEPS = polistirolo (generic EPS)
-Databases.materials.StyrofoamBluefoamXPS = polistirolo \"Blue foam\" (XPS)
-Databases.materials.Titanium = Titanium
-Databases.materials.Quantumtubing = Quantum tubing
-Databases.materials.BlueTube = Blue tube
+material.acrylic = Acrilico
+material.aluminum = Aluminum
+material.balsa = Balsa
+material.basswood = Basswood
+material.birch = Betulla
+material.brass = Brass
+material.cardboard = Cartoncino
+material.carbon_fiber = Fibra di carbonio
+material.cork = Sughero
+material.depron_xps = Depron (XPS)
+material.fiberglass = Fibra di vetro
+material.kraft_phenolic = Kraft phenolic
+material.maple = Acero
+material.paper_office = Carta (ufficio)
+material.pine = Pino
+material.plywood_birch = Compensato (betulla)
+material.polycarbonate_lexan = Policarbonato (Lexan)
+material.polystyrene = Polistirene
+material.pvc = PVC
+material.spruce = Abete rosso
+material.steel = Steel
+material.styrofoam_generic_eps = polistirolo (generic EPS)
+material.styrofoam_blue_foam_xps = polistirolo \"Blue foam\" (XPS)
+material.titanium = Titanium
+material.quantum_tubing = Quantum tubing
+material.blue_tube = Blue tube
!SURFACE_MATERIAL
-Databases.materials.Ripstopnylon = Ripstop nylon
-Databases.materials.Mylar = Mylar
-Databases.materials.Polyethylenethin = Polyethylene (thin)
-Databases.materials.Polyethyleneheavy = Polyethylene (heavy)
-Databases.materials.Silk = Seta
-Databases.materials.Paperoffice = Carta (ufficio)
-Databases.materials.Cellophane = Cellophane
-Databases.materials.Crepepaper = Cr\u00eape carta
+material.ripstop_nylon = Ripstop nylon
+material.mylar = Mylar
+material.polyethylene_thin = Polyethylene (thin)
+material.polyethylene_heavy = Polyethylene (heavy)
+material.silk = Seta
+material.paper_office = Carta (ufficio)
+material.cellophane = Cellophane
+material.crepe_paper = Cr\u00eape carta
! LINE_MATERIAL
-Databases.materials.Threadheavy-duty = Thread (heavy-duty)
-Databases.materials.Elasticcordround2mm = Elastic cord (round 2mm, 1/16 in)
-Databases.materials.Elasticcordflat6mm = Elastic cord (flat 6mm, 1/4 in)
-Databases.materials.Elasticcordflat12mm = Elastic cord (flat 12mm, 1/2 in)
-Databases.materials.Elasticcordflat19mm = Elastic cord (flat 19mm, 3/4 in)
-Databases.materials.Elasticcordflat25mm = Elastic cord (flat 25mm, 1 in)
-Databases.materials.Braidednylon2mm = Braided nylon (2 mm, 1/16 in)
-Databases.materials.Braidednylon3mm = Braided nylon (3 mm, 1/8 in)
-Databases.materials.Tubularnylon11mm = Tubular nylon (11 mm, 7/16 in)
-Databases.materials.Tubularnylon14mm = Tubular nylon (14 mm, 9/16 in)
-Databases.materials.Tubularnylon25mm = Tubular nylon (25 mm, 1 in)
+material.thread_heavy_duty = Thread (heavy-duty)
+material.elastic_cord_round_2_mm_1_16_in = Elastic cord (round 2mm, 1/16 in)
+material.elastic_cord_flat_6_mm_1_4_in = Elastic cord (flat 6mm, 1/4 in)
+material.elastic_cord_flat_12_mm_1_2_in = Elastic cord (flat 12mm, 1/2 in)
+material.elastic_cord_flat_19_mm_3_4_in = Elastic cord (flat 19mm, 3/4 in)
+material.elastic_cord_flat_25_mm_1_in = Elastic cord (flat 25mm, 1 in)
+material.braided_nylon_2_mm_1_16_in = Braided nylon (2 mm, 1/16 in)
+material.braided_nylon_3_mm_1_8_in = Braided nylon (3 mm, 1/8 in)
+material.tubular_nylon_11_mm_7_16_in = Tubular nylon (11 mm, 7/16 in)
+material.tubular_nylon_14_mm_9_16_in = Tubular nylon (14 mm, 9/16 in)
+material.tubular_nylon_25_mm_1_in = Tubular nylon (25 mm, 1 in)
! ExternalComponent
ExternalComponent.Rough = Ruvido
! Material database
! BULK_MATERIAL
- Databases.materials.Acrylic = Akryl
- Databases.materials.Aluminum = Aluminium
- Databases.materials.Balsa = Balsa
- Databases.materials.Basswood = Lipa
- Databases.materials.Birch = Brzoza
- Databases.materials.Brass = Mosi\u0105dz
- Databases.materials.Cardboard = Karton
- Databases.materials.Carbonfiber = W\u0142ókno w\u0119glowe
- Databases.materials.Cork = Korek
- Databases.materials.DepronXPS = Depron (XPS)
- Databases.materials.Fiberglass = W\u0142ókno szklane
- Databases.materials.Kraftphenolic = Kraft fenolowy
- Databases.materials.Maple = Klon
- Databases.materials.Paperoffice = Papier (biurowy)
- Databases.materials.Pine = Sosna
- Databases.materials.Plywoodbirch = Sklejka (brzoza)
- Databases.materials.PolycarbonateLexan = Poliw\u0119glan (Lexan)
- Databases.materials.Polystyrene = Polistyren
- Databases.materials.PVC = PVC
- Databases.materials.Spruce = \u015Awierk
- Databases.materials.Steel = Stal
- Databases.materials.StyrofoamgenericEPS = Styropian (zwyk\u0142y EPS)
- Databases.materials.StyrofoamBluefoamXPS = Styropian \"kolorowy\" (XPS)
- Databases.materials.Titanium = Tytan
- Databases.materials.Quantumtubing = Tuby kwantowe
- Databases.materials.BlueTube = Blue tube
+ material.acrylic = Akryl
+ material.aluminum = Aluminium
+ material.balsa = Balsa
+ material.basswood = Lipa
+ material.birch = Brzoza
+ material.brass = Mosi\u0105dz
+ material.cardboard = Karton
+ material.carbon_fiber = W\u0142ókno w\u0119glowe
+ material.cork = Korek
+ material.depron_xps = Depron (XPS)
+ material.fiberglass = W\u0142ókno szklane
+ material.kraft_phenolic = Kraft fenolowy
+ material.maple = Klon
+ material.paper_office = Papier (biurowy)
+ material.pine = Sosna
+ material.plywood_birch = Sklejka (brzoza)
+ material.polycarbonate_lexan = Poliw\u0119glan (Lexan)
+ material.polystyrene = Polistyren
+ material.pvc = PVC
+ material.spruce = \u015Awierk
+ material.steel = Stal
+ material.styrofoam_generic_eps = Styropian (zwyk\u0142y EPS)
+ material.styrofoam_blue_foam_xps = Styropian \"kolorowy\" (XPS)
+ material.titanium = Tytan
+ material.quantum_tubing = Tuby kwantowe
+ material.blue_tube = Blue tube
!SURFACE_MATERIAL
- Databases.materials.Ripstopnylon = Nylon Rip-stop
- Databases.materials.Mylar = Mylar
- Databases.materials.Polyethylenethin = Polietylen (cienki)
- Databases.materials.Polyethyleneheavy = Polietylen (ci\u0119\u017Cki)
- Databases.materials.Silk = Jedwab
- Databases.materials.Paperoffice = Papier (biurowy)
- Databases.materials.Cellophane = Celofan
- Databases.materials.Crepepaper = Papier marszczony, krepina
+ material.ripstop_nylon = Nylon Rip-stop
+ material.mylar = Mylar
+ material.polyethylene_thin = Polietylen (cienki)
+ material.polyethylene_heavy = Polietylen (ci\u0119\u017Cki)
+ material.silk = Jedwab
+ material.paper_office = Papier (biurowy)
+ material.cellophane = Celofan
+ material.crepe_paper = Papier marszczony, krepina
! LINE_MATERIAL
- Databases.materials.Threadheavy-duty = Ni\u0107 (wytrzyma\u0142a)
- Databases.materials.Elasticcordround2mm = Przewód elastyczny (okr\u0105g\u0142y 2mm)
- Databases.materials.Elasticcordflat6mm = Przewód elastyczny (p\u0142aski 6mm)
- Databases.materials.Elasticcordflat12mm = Przewód elastyczny (p\u0142aski 12 mm)
- Databases.materials.Elasticcordflat19mm = Przewód elastyczny (p\u0142aski 19 mm)
- Databases.materials.Elasticcordflat25mm = Przewód elastyczny (p\u0142aski 25mm)
- Databases.materials.Braidednylon2mm = Nylon spleciony (2 mm)
- Databases.materials.Braidednylon3mm = Nylon spleciony (3 mm)
- Databases.materials.Tubularnylon11mm = Nylon rurkowy (11 mm)
- Databases.materials.Tubularnylon14mm = Nylon rurkowy (14 mm)
- Databases.materials.Tubularnylon25mm = Nylon rurkowy (25 mm)
+ material.thread_heavy_duty = Ni\u0107 (wytrzyma\u0142a)
+ material.elastic_cord_round_2_mm_1_16_in = Przewód elastyczny (okr\u0105g\u0142y 2mm)
+ material.elastic_cord_flat_6_mm_1_4_in = Przewód elastyczny (p\u0142aski 6mm)
+ material.elastic_cord_flat_12_mm_1_2_in = Przewód elastyczny (p\u0142aski 12 mm)
+ material.elastic_cord_flat_19_mm_3_4_in = Przewód elastyczny (p\u0142aski 19 mm)
+ material.elastic_cord_flat_25_mm_1_in = Przewód elastyczny (p\u0142aski 25mm)
+ material.braided_nylon_2_mm_1_16_in = Nylon spleciony (2 mm)
+ material.braided_nylon_3_mm_1_8_in = Nylon spleciony (3 mm)
+ material.tubular_nylon_11_mm_7_16_in = Nylon rurkowy (11 mm)
+ material.tubular_nylon_14_mm_9_16_in = Nylon rurkowy (14 mm)
+ material.tubular_nylon_25_mm_1_in = Nylon rurkowy (25 mm)
! ExternalComponent
ExternalComponent.Rough = Chropowate
Databases.materials.types.Line = \u041b\u0438\u043d\u0435\u0439\u043d\u044b\u0439
Databases.materials.types.Surface = \u041f\u043e\u0432\u0435\u0440\u0445\u043d\u043e\u0441\u0442\u043d\u044b\u0439
! BULK_MATERIAL
-Databases.materials.Acrylic = \u0410\u043a\u0440\u0438\u043b
-Databases.materials.Aluminum = \u0410\u043b\u044e\u043c\u0438\u043d\u0438\u0439
-Databases.materials.Balsa = \u0411\u0430\u043b\u044c\u0441\u0430
-Databases.materials.Basswood = \u0410\u043c\u0435\u0440\u0438\u043a\u0430\u043d\u0441\u043a\u0430\u044f \u043b\u0438\u043f\u0430
-Databases.materials.Birch = \u0411\u0435\u0440\u0435\u0437\u0430
-Databases.materials.Brass = \u041b\u0430\u0442\u0443\u043d\u044c
-Databases.materials.Cardboard = \u041a\u0430\u0440\u0442\u043e\u043d
-Databases.materials.Carbonfiber = \u0423\u0433\u043b\u0435\u0432\u043e\u043b\u043e\u043a\u043d\u043e
-Databases.materials.Cork = \u041f\u0440\u043e\u0431\u043a\u0430
-Databases.materials.DepronXPS = \u0414\u0435\u043f\u0440\u043e\u043d (XPS)
-Databases.materials.Fiberglass = \u0421\u0442\u0435\u043a\u043b\u043e\u0432\u043e\u043b\u043e\u043a\u043d\u043e
-Databases.materials.Kraftphenolic = \u041f\u0440\u043e\u043f\u0438\u0442\u0430\u043d\u043d\u0430\u044f \u043a\u0440\u0430\u0444\u0442-\u0431\u0443\u043c\u0430\u0433\u0430
-Databases.materials.Maple = \u041a\u043b\u0451\u043d
-Databases.materials.Paperoffice = \u0411\u0443\u043c\u0430\u0433\u0430 (\u043e\u0444\u0438\u0441\u043d\u0430\u044f)
-Databases.materials.Pine = \u0421\u043e\u0441\u043d\u0430
-Databases.materials.Plywoodbirch = \u0424\u0430\u043d\u0435\u0440\u0430 (\u0431\u0435\u0440\u0435\u0437\u043e\u0432\u0430\u044f)
-Databases.materials.PolycarbonateLexan = \u041f\u043e\u043b\u0438\u043a\u0430\u0440\u0431\u043e\u043d\u0430\u0442 (\u041b\u0435\u043a\u0441\u0430\u043d)
-Databases.materials.Polystyrene = \u041f\u043e\u043b\u0438\u0441\u0442\u0438\u0440\u043e\u043b
-Databases.materials.PVC = \u041f\u0412\u0425
-Databases.materials.Spruce = \u0415\u043b\u044c
-Databases.materials.Steel = \u0421\u0442\u0430\u043b\u044c
-Databases.materials.StyrofoamgenericEPS = \u041f\u0435\u043d\u043e\u043f\u043b\u0430\u0441\u0442 (\u043e\u0431\u044b\u0447\u043d\u044b\u0439 EPS)
-Databases.materials.StyrofoamBluefoamXPS = \u041f\u0435\u043d\u043e\u043f\u043b\u0430\u0441\u0442 "Blue foam" (XPS)
-Databases.materials.Titanium = \u0422\u0438\u0442\u0430\u043d
-Databases.materials.Quantumtubing = Quantum tubing
-Databases.materials.BlueTube = Blue tube
+material.acrylic = \u0410\u043a\u0440\u0438\u043b
+material.aluminum = \u0410\u043b\u044e\u043c\u0438\u043d\u0438\u0439
+material.balsa = \u0411\u0430\u043b\u044c\u0441\u0430
+material.basswood = \u0410\u043c\u0435\u0440\u0438\u043a\u0430\u043d\u0441\u043a\u0430\u044f \u043b\u0438\u043f\u0430
+material.birch = \u0411\u0435\u0440\u0435\u0437\u0430
+material.brass = \u041b\u0430\u0442\u0443\u043d\u044c
+material.cardboard = \u041a\u0430\u0440\u0442\u043e\u043d
+material.carbon_fiber = \u0423\u0433\u043b\u0435\u0432\u043e\u043b\u043e\u043a\u043d\u043e
+material.cork = \u041f\u0440\u043e\u0431\u043a\u0430
+material.depron_xps = \u0414\u0435\u043f\u0440\u043e\u043d (XPS)
+material.fiberglass = \u0421\u0442\u0435\u043a\u043b\u043e\u0432\u043e\u043b\u043e\u043a\u043d\u043e
+material.kraft_phenolic = \u041f\u0440\u043e\u043f\u0438\u0442\u0430\u043d\u043d\u0430\u044f \u043a\u0440\u0430\u0444\u0442-\u0431\u0443\u043c\u0430\u0433\u0430
+material.maple = \u041a\u043b\u0451\u043d
+material.paper_office = \u0411\u0443\u043c\u0430\u0433\u0430 (\u043e\u0444\u0438\u0441\u043d\u0430\u044f)
+material.pine = \u0421\u043e\u0441\u043d\u0430
+material.plywood_birch = \u0424\u0430\u043d\u0435\u0440\u0430 (\u0431\u0435\u0440\u0435\u0437\u043e\u0432\u0430\u044f)
+material.polycarbonate_lexan = \u041f\u043e\u043b\u0438\u043a\u0430\u0440\u0431\u043e\u043d\u0430\u0442 (\u041b\u0435\u043a\u0441\u0430\u043d)
+material.polystyrene = \u041f\u043e\u043b\u0438\u0441\u0442\u0438\u0440\u043e\u043b
+material.pvc = \u041f\u0412\u0425
+material.spruce = \u0415\u043b\u044c
+material.steel = \u0421\u0442\u0430\u043b\u044c
+material.styrofoam_generic_eps = \u041f\u0435\u043d\u043e\u043f\u043b\u0430\u0441\u0442 (\u043e\u0431\u044b\u0447\u043d\u044b\u0439 EPS)
+material.styrofoam_blue_foam_xps = \u041f\u0435\u043d\u043e\u043f\u043b\u0430\u0441\u0442 "Blue foam" (XPS)
+material.titanium = \u0422\u0438\u0442\u0430\u043d
+material.quantum_tubing = Quantum tubing
+material.blue_tube = Blue tube
!SURFACE_MATERIAL
-Databases.materials.Ripstopnylon = \u041d\u0435\u0439\u043b\u043e\u043d\u043e\u0432\u044b\u0439 \u0440\u0438\u043f\u0441\u0442\u043e\u043f
-Databases.materials.Mylar = \u041c\u0430\u0439\u043b\u0430\u0440
-Databases.materials.Polyethylenethin = \u041f\u043e\u043b\u0438\u044d\u0442\u0438\u043b\u0435\u043d (\u0442\u043e\u043d\u043a\u0438\u0439)
-Databases.materials.Polyethyleneheavy = \u041f\u043e\u043b\u0438\u044d\u0442\u0438\u043b\u0435\u043d (\u043f\u043b\u043e\u0442\u043d\u044b\u0439)
-Databases.materials.Silk = \u0428\u0435\u043b\u043a
-Databases.materials.Paperoffice = \u0411\u0443\u043c\u0430\u0433\u0430 (\u043e\u0444\u0438\u0441\u043d\u0430\u044f)
-Databases.materials.Cellophane = \u0426\u0435\u043b\u043b\u043e\u0444\u0430\u043d
-Databases.materials.Crepepaper = Cr\u00eape paper
+material.ripstop_nylon = \u041d\u0435\u0439\u043b\u043e\u043d\u043e\u0432\u044b\u0439 \u0440\u0438\u043f\u0441\u0442\u043e\u043f
+material.mylar = \u041c\u0430\u0439\u043b\u0430\u0440
+material.polyethylene_thin = \u041f\u043e\u043b\u0438\u044d\u0442\u0438\u043b\u0435\u043d (\u0442\u043e\u043d\u043a\u0438\u0439)
+material.polyethylene_heavy = \u041f\u043e\u043b\u0438\u044d\u0442\u0438\u043b\u0435\u043d (\u043f\u043b\u043e\u0442\u043d\u044b\u0439)
+material.silk = \u0428\u0435\u043b\u043a
+material.paper_office = \u0411\u0443\u043c\u0430\u0433\u0430 (\u043e\u0444\u0438\u0441\u043d\u0430\u044f)
+material.cellophane = \u0426\u0435\u043b\u043b\u043e\u0444\u0430\u043d
+material.crepe_paper = Cr\u00eape paper
! LINE_MATERIAL
-Databases.materials.Threadheavy-duty = \u0421\u0443\u0440\u043e\u0432\u0430\u044f \u043d\u0438\u0442\u044c
-Databases.materials.Elasticcordround2mm = \u042d\u043b\u0430\u0441\u0442\u0438\u0447\u043d\u044b\u0439 \u0448\u043d\u0443\u0440 (\u043a\u0440\u0443\u0433\u043b\u044b\u0439 2mm, 1/16 in)
-Databases.materials.Elasticcordflat6mm = \u042d\u043b\u0430\u0441\u0442\u0438\u0447\u043d\u044b\u0439 \u0448\u043d\u0443\u0440 (\u043f\u043b\u043e\u0441\u043a\u0438\u0439 6mm, 1/4 in)
-Databases.materials.Elasticcordflat12mm = \u042d\u043b\u0430\u0441\u0442\u0438\u0447\u043d\u044b\u0439 \u0448\u043d\u0443\u0440 (\u043f\u043b\u043e\u0441\u043a\u0438\u0439 12mm, 1/2 in)
-Databases.materials.Elasticcordflat19mm = \u042d\u043b\u0430\u0441\u0442\u0438\u0447\u043d\u044b\u0439 \u0448\u043d\u0443\u0440 (\u043f\u043b\u043e\u0441\u043a\u0438\u0439 19mm, 3/4 in)
-Databases.materials.Elasticcordflat25mm = \u042d\u043b\u0430\u0441\u0442\u0438\u0447\u043d\u044b\u0439 \u0448\u043d\u0443\u0440 (\u043f\u043b\u043e\u0441\u043a\u0438\u0439 25mm, 1 in)
-Databases.materials.Braidednylon2mm = \u041f\u043b\u0435\u0442\u0435\u043d\u044b\u0439 \u043d\u0435\u0439\u043b\u043e\u043d (2 mm, 1/16 in)
-Databases.materials.Braidednylon3mm = \u041f\u043b\u0435\u0442\u0435\u043d\u044b\u0439 \u043d\u0435\u0439\u043b\u043e\u043d (3 mm, 1/8 in)
-Databases.materials.Tubularnylon11mm = \u0422\u0440\u0443\u0431\u0447\u0430\u0442\u044b\u0439 \u043d\u0435\u0439\u043b\u043e\u043d (11 mm, 7/16 in)
-Databases.materials.Tubularnylon14mm = \u0422\u0440\u0443\u0431\u0447\u0430\u0442\u044b\u0439 \u043d\u0435\u0439\u043b\u043e\u043d (14 mm, 9/16 in)
-Databases.materials.Tubularnylon25mm = \u0422\u0440\u0443\u0431\u0447\u0430\u0442\u044b\u0439 \u043d\u0435\u0439\u043b\u043e\u043d (25 mm, 1 in)
+material.thread_heavy_duty = \u0421\u0443\u0440\u043e\u0432\u0430\u044f \u043d\u0438\u0442\u044c
+material.elastic_cord_round_2_mm_1_16_in = \u042d\u043b\u0430\u0441\u0442\u0438\u0447\u043d\u044b\u0439 \u0448\u043d\u0443\u0440 (\u043a\u0440\u0443\u0433\u043b\u044b\u0439 2mm, 1/16 in)
+material.elastic_cord_flat_6_mm_1_4_in = \u042d\u043b\u0430\u0441\u0442\u0438\u0447\u043d\u044b\u0439 \u0448\u043d\u0443\u0440 (\u043f\u043b\u043e\u0441\u043a\u0438\u0439 6mm, 1/4 in)
+material.elastic_cord_flat_12_mm_1_2_in = \u042d\u043b\u0430\u0441\u0442\u0438\u0447\u043d\u044b\u0439 \u0448\u043d\u0443\u0440 (\u043f\u043b\u043e\u0441\u043a\u0438\u0439 12mm, 1/2 in)
+material.elastic_cord_flat_19_mm_3_4_in = \u042d\u043b\u0430\u0441\u0442\u0438\u0447\u043d\u044b\u0439 \u0448\u043d\u0443\u0440 (\u043f\u043b\u043e\u0441\u043a\u0438\u0439 19mm, 3/4 in)
+material.elastic_cord_flat_25_mm_1_in = \u042d\u043b\u0430\u0441\u0442\u0438\u0447\u043d\u044b\u0439 \u0448\u043d\u0443\u0440 (\u043f\u043b\u043e\u0441\u043a\u0438\u0439 25mm, 1 in)
+material.braided_nylon_2_mm_1_16_in = \u041f\u043b\u0435\u0442\u0435\u043d\u044b\u0439 \u043d\u0435\u0439\u043b\u043e\u043d (2 mm, 1/16 in)
+material.braided_nylon_3_mm_1_8_in = \u041f\u043b\u0435\u0442\u0435\u043d\u044b\u0439 \u043d\u0435\u0439\u043b\u043e\u043d (3 mm, 1/8 in)
+material.tubular_nylon_11_mm_7_16_in = \u0422\u0440\u0443\u0431\u0447\u0430\u0442\u044b\u0439 \u043d\u0435\u0439\u043b\u043e\u043d (11 mm, 7/16 in)
+material.tubular_nylon_14_mm_9_16_in = \u0422\u0440\u0443\u0431\u0447\u0430\u0442\u044b\u0439 \u043d\u0435\u0439\u043b\u043e\u043d (14 mm, 9/16 in)
+material.tubular_nylon_25_mm_1_in = \u0422\u0440\u0443\u0431\u0447\u0430\u0442\u044b\u0439 \u043d\u0435\u0439\u043b\u043e\u043d (25 mm, 1 in)
! ExternalComponent
ExternalComponent.Rough = \u0427\u0435\u0440\u043d\u043e\u0432\u0430\u044f
--- /dev/null
+#!/bin/bash
+
+# Usage:
+# ./rename <file-containing-rename-keys> <files_to_modify ...>
+
+RENAME="$1"
+shift
+
+cat "$RENAME" | while read line ; do
+
+ FROM=`echo $line | awk '{print $1}'`
+ TO=`echo $line | awk '{print $2}'`
+
+ sed -i "s/$FROM/$TO/g" "$@"
+
+done
package net.sf.openrocket.database;
+import net.sf.openrocket.l10n.Translator;
import net.sf.openrocket.logging.LogHelper;
import net.sf.openrocket.material.Material;
+import net.sf.openrocket.material.Material.Type;
import net.sf.openrocket.material.MaterialStorage;
import net.sf.openrocket.startup.Application;
import net.sf.openrocket.util.MathUtil;
*/
public class Databases {
private static final LogHelper log = Application.getLogger();
-
+ private static final Translator trans = Application.getTranslator();
+
+
/* Static implementations of specific databases: */
-
+
/**
* A database of bulk materials (with bulk densities).
*/
* A database of linear material (with length densities).
*/
public static final Database<Material> LINE_MATERIAL = new Database<Material>();
-
-
-
+
+
+
static {
-
+
// Add default materials
- BULK_MATERIAL.add(Material.newSystemMaterial(Material.Type.BULK,"Acrylic", 1190));
- BULK_MATERIAL.add(Material.newSystemMaterial(Material.Type.BULK,"Aluminum", 2700));
- BULK_MATERIAL.add(Material.newSystemMaterial(Material.Type.BULK,"Balsa", 170));
- BULK_MATERIAL.add(Material.newSystemMaterial(Material.Type.BULK,"Basswood", 500));
- BULK_MATERIAL.add(Material.newSystemMaterial(Material.Type.BULK,"Birch", 670));
- BULK_MATERIAL.add(Material.newSystemMaterial(Material.Type.BULK,"Brass", 8600));
- BULK_MATERIAL.add(Material.newSystemMaterial(Material.Type.BULK,"Cardboard", 680));
- BULK_MATERIAL.add(Material.newSystemMaterial(Material.Type.BULK,"Carbonfiber", 1780));
- BULK_MATERIAL.add(Material.newSystemMaterial(Material.Type.BULK,"Cork", 240));
- BULK_MATERIAL.add(Material.newSystemMaterial(Material.Type.BULK,"DepronXPS", 40));
- BULK_MATERIAL.add(Material.newSystemMaterial(Material.Type.BULK,"Fiberglass", 1850));
- BULK_MATERIAL.add(Material.newSystemMaterial(Material.Type.BULK,"Kraftphenolic", 950));
- BULK_MATERIAL.add(Material.newSystemMaterial(Material.Type.BULK,"Maple", 755));
- BULK_MATERIAL.add(Material.newSystemMaterial(Material.Type.BULK,"Paperoffice", 820));
- BULK_MATERIAL.add(Material.newSystemMaterial(Material.Type.BULK,"Pine", 530));
- BULK_MATERIAL.add(Material.newSystemMaterial(Material.Type.BULK,"Plywoodbirch", 630));
- BULK_MATERIAL.add(Material.newSystemMaterial(Material.Type.BULK,"PolycarbonateLexan", 1200));
- BULK_MATERIAL.add(Material.newSystemMaterial(Material.Type.BULK,"Polystyrene", 1050));
- BULK_MATERIAL.add(Material.newSystemMaterial(Material.Type.BULK,"PVC", 1390));
- BULK_MATERIAL.add(Material.newSystemMaterial(Material.Type.BULK,"Spruce", 450));
- BULK_MATERIAL.add(Material.newSystemMaterial(Material.Type.BULK,"Steel", 7850));
- BULK_MATERIAL.add(Material.newSystemMaterial(Material.Type.BULK,"StyrofoamgenericEPS", 20));
- // BULK_MATERIAL.add(Material.newSystemMaterial(Material.Type.BULK,"Styrofoam (Blue foam, XPS)", 32));
- BULK_MATERIAL.add(Material.newSystemMaterial(Material.Type.BULK,"StyrofoamBluefoamXPS", 32));
- BULK_MATERIAL.add(Material.newSystemMaterial(Material.Type.BULK,"Titanium", 4500));
- BULK_MATERIAL.add(Material.newSystemMaterial(Material.Type.BULK,"Quantumtubing", 1050));
- BULK_MATERIAL.add(Material.newSystemMaterial(Material.Type.BULK,"BlueTube", 1300));
-
- SURFACE_MATERIAL.add(Material.newSystemMaterial(Material.Type.SURFACE,"Ripstopnylon", 0.067));
- SURFACE_MATERIAL.add(Material.newSystemMaterial(Material.Type.SURFACE,"Mylar", 0.021));
- SURFACE_MATERIAL.add(Material.newSystemMaterial(Material.Type.SURFACE,"Polyethylenethin", 0.015));
- SURFACE_MATERIAL.add(Material.newSystemMaterial(Material.Type.SURFACE,"Polyethyleneheavy", 0.040));
- SURFACE_MATERIAL.add(Material.newSystemMaterial(Material.Type.SURFACE,"Silk", 0.060));
- SURFACE_MATERIAL.add(Material.newSystemMaterial(Material.Type.SURFACE,"Paperoffice", 0.080));
- SURFACE_MATERIAL.add(Material.newSystemMaterial(Material.Type.SURFACE,"Cellophane", 0.018));
- SURFACE_MATERIAL.add(Material.newSystemMaterial(Material.Type.SURFACE,"Crepepaper", 0.025));
-
- //// Thread (heavy-duty)
- LINE_MATERIAL.add(Material.newSystemMaterial(Material.Type.LINE,"Threadheavy-duty", 0.0003));
- //// Elastic cord (round 2mm, 1/16 in)
- LINE_MATERIAL.add(Material.newSystemMaterial(Material.Type.LINE,"Elasticcordround2mm", 0.0018));
- //// Elastic cord (flat 6mm, 1/4 in)
- LINE_MATERIAL.add(Material.newSystemMaterial(Material.Type.LINE,"Elasticcordflat6mm", 0.0043));
- //// Elastic cord (flat 12mm, 1/2 in)
- LINE_MATERIAL.add(Material.newSystemMaterial(Material.Type.LINE,"Elasticcordflat12mm", 0.008));
- //// Elastic cord (flat 19mm, 3/4 in)
- LINE_MATERIAL.add(Material.newSystemMaterial(Material.Type.LINE,"Elasticcordflat19mm", 0.0012));
- //// Elastic cord (flat 25mm, 1 in)
- LINE_MATERIAL.add(Material.newSystemMaterial(Material.Type.LINE,"Elasticcordflat25mm", 0.0016));
- //// Braided nylon (2 mm, 1/16 in)
- LINE_MATERIAL.add(Material.newSystemMaterial(Material.Type.LINE,"Braidednylon2mm", 0.001));
- //// Braided nylon (3 mm, 1/8 in)
- LINE_MATERIAL.add(Material.newSystemMaterial(Material.Type.LINE,"Braidednylon3mm", 0.0035));
- //// Tubular nylon (11 mm, 7/16 in)
- LINE_MATERIAL.add(Material.newSystemMaterial(Material.Type.LINE,"Tubularnylon11mm", 0.013));
- //// Tubular nylon (14 mm, 9/16 in)
- LINE_MATERIAL.add(Material.newSystemMaterial(Material.Type.LINE,"Tubularnylon14mm", 0.016));
- //// Tubular nylon (25 mm, 1 in)
- LINE_MATERIAL.add(Material.newSystemMaterial(Material.Type.LINE,"Tubularnylon25mm", 0.029));
-
-
+ BULK_MATERIAL.add(newMaterial(Material.Type.BULK, "Acrylic", 1190));
+ BULK_MATERIAL.add(newMaterial(Material.Type.BULK, "Aluminum", 2700));
+ BULK_MATERIAL.add(newMaterial(Material.Type.BULK, "Balsa", 170));
+ BULK_MATERIAL.add(newMaterial(Material.Type.BULK, "Basswood", 500));
+ BULK_MATERIAL.add(newMaterial(Material.Type.BULK, "Birch", 670));
+ BULK_MATERIAL.add(newMaterial(Material.Type.BULK, "Brass", 8600));
+ BULK_MATERIAL.add(newMaterial(Material.Type.BULK, "Cardboard", 680));
+ BULK_MATERIAL.add(newMaterial(Material.Type.BULK, "Carbon fiber", 1780));
+ BULK_MATERIAL.add(newMaterial(Material.Type.BULK, "Cork", 240));
+ BULK_MATERIAL.add(newMaterial(Material.Type.BULK, "Depron (XPS)", 40));
+ BULK_MATERIAL.add(newMaterial(Material.Type.BULK, "Fiberglass", 1850));
+ BULK_MATERIAL.add(newMaterial(Material.Type.BULK, "Kraft phenolic", 950));
+ BULK_MATERIAL.add(newMaterial(Material.Type.BULK, "Maple", 755));
+ BULK_MATERIAL.add(newMaterial(Material.Type.BULK, "Paper (office)", 820));
+ BULK_MATERIAL.add(newMaterial(Material.Type.BULK, "Pine", 530));
+ BULK_MATERIAL.add(newMaterial(Material.Type.BULK, "Plywood (birch)", 630));
+ BULK_MATERIAL.add(newMaterial(Material.Type.BULK, "Polycarbonate (Lexan)", 1200));
+ BULK_MATERIAL.add(newMaterial(Material.Type.BULK, "Polystyrene", 1050));
+ BULK_MATERIAL.add(newMaterial(Material.Type.BULK, "PVC", 1390));
+ BULK_MATERIAL.add(newMaterial(Material.Type.BULK, "Spruce", 450));
+ BULK_MATERIAL.add(newMaterial(Material.Type.BULK, "Steel", 7850));
+ BULK_MATERIAL.add(newMaterial(Material.Type.BULK, "Styrofoam (generic EPS)", 20));
+ BULK_MATERIAL.add(newMaterial(Material.Type.BULK, "Styrofoam \"Blue foam\" (XPS)", 32));
+ BULK_MATERIAL.add(newMaterial(Material.Type.BULK, "Titanium", 4500));
+ BULK_MATERIAL.add(newMaterial(Material.Type.BULK, "Quantum tubing", 1050));
+ BULK_MATERIAL.add(newMaterial(Material.Type.BULK, "Blue tube", 1300));
+
+ SURFACE_MATERIAL.add(newMaterial(Material.Type.SURFACE, "Ripstop nylon", 0.067));
+ SURFACE_MATERIAL.add(newMaterial(Material.Type.SURFACE, "Mylar", 0.021));
+ SURFACE_MATERIAL.add(newMaterial(Material.Type.SURFACE, "Polyethylene (thin)", 0.015));
+ SURFACE_MATERIAL.add(newMaterial(Material.Type.SURFACE, "Polyethylene (heavy)", 0.040));
+ SURFACE_MATERIAL.add(newMaterial(Material.Type.SURFACE, "Silk", 0.060));
+ SURFACE_MATERIAL.add(newMaterial(Material.Type.SURFACE, "Paper (office)", 0.080));
+ SURFACE_MATERIAL.add(newMaterial(Material.Type.SURFACE, "Cellophane", 0.018));
+ SURFACE_MATERIAL.add(newMaterial(Material.Type.SURFACE, "Cr\u00eape paper", 0.025));
+
+ LINE_MATERIAL.add(newMaterial(Material.Type.LINE, "Thread (heavy-duty)", 0.0003));
+ LINE_MATERIAL.add(newMaterial(Material.Type.LINE, "Elastic cord (round 2 mm, 1/16 in)", 0.0018));
+ LINE_MATERIAL.add(newMaterial(Material.Type.LINE, "Elastic cord (flat 6 mm, 1/4 in)", 0.0043));
+ LINE_MATERIAL.add(newMaterial(Material.Type.LINE, "Elastic cord (flat 12 mm, 1/2 in)", 0.008));
+ LINE_MATERIAL.add(newMaterial(Material.Type.LINE, "Elastic cord (flat 19 mm, 3/4 in)", 0.0012));
+ LINE_MATERIAL.add(newMaterial(Material.Type.LINE, "Elastic cord (flat 25 mm, 1 in)", 0.0016));
+ LINE_MATERIAL.add(newMaterial(Material.Type.LINE, "Braided nylon (2 mm, 1/16 in)", 0.001));
+ LINE_MATERIAL.add(newMaterial(Material.Type.LINE, "Braided nylon (3 mm, 1/8 in)", 0.0035));
+ LINE_MATERIAL.add(newMaterial(Material.Type.LINE, "Tubular nylon (11 mm, 7/16 in)", 0.013));
+ LINE_MATERIAL.add(newMaterial(Material.Type.LINE, "Tubular nylon (14 mm, 9/16 in)", 0.016));
+ LINE_MATERIAL.add(newMaterial(Material.Type.LINE, "Tubular nylon (25 mm, 1 in)", 0.029));
+
+
// Add user-defined materials
for (Material m : Application.getPreferences().getUserMaterials()) {
switch (m.getType()) {
case LINE:
LINE_MATERIAL.add(m);
break;
-
+
case SURFACE:
SURFACE_MATERIAL.add(m);
break;
-
+
case BULK:
BULK_MATERIAL.add(m);
break;
-
+
default:
log.warn("ERROR: Unknown material type " + m);
}
}
-
+
// Add database storage listener
MaterialStorage listener = new MaterialStorage();
LINE_MATERIAL.addDatabaseListener(listener);
SURFACE_MATERIAL.addDatabaseListener(listener);
BULK_MATERIAL.addDatabaseListener(listener);
}
-
-
+
+
+ private static Material newMaterial(Type type, String baseName, double density) {
+ String name = trans.get("material", baseName);
+ return Material.newMaterial(type, name, density, false);
+ }
+
+
+
+
/*
* Used just for ensuring initialization of the class.
*/
public static void fakeMethod() {
-
+
}
-
-
+
/**
* Find a material from the database with the specified type and name. Returns
* <code>null</code> if the specified material could not be found.
+ * <p>
+ * This method will attempt to localize the material name to the current locale, or use
+ * the provided name if unable to do so.
*
- * @param type the material type.
- * @param name the material name in the database.
- * @return the material, or <code>null</code> if not found.
+ * @param type the material type.
+ * @param baseName the material base name in the database.
+ * @return the material, or <code>null</code> if not found.
*/
- public static Material findMaterial(Material.Type type, String name) {
+ public static Material findMaterial(Material.Type type, String baseName) {
Database<Material> db;
switch (type) {
case BULK:
default:
throw new IllegalArgumentException("Illegal material type: " + type);
}
-
+
+ String name = trans.get("material", baseName);
+
for (Material m : db) {
if (m.getName().equalsIgnoreCase(name)) {
return m;
}
return null;
}
-
-
+
+
/**
* Find a material from the database or return a new user defined material if the specified
* material with the specified density is not found.
+ * <p>
+ * This method will attempt to localize the material name to the current locale, or use
+ * the provided name if unable to do so.
*
* @param type the material type.
- * @param name the material name.
+ * @param baseName the base name of the material.
* @param density the density of the material.
* @return the material object from the database or a new material.
*/
- public static Material findMaterial(Material.Type type, String key, String name, double density) {
+ public static Material findMaterial(Material.Type type, String baseName, double density) {
Database<Material> db;
switch (type) {
case BULK:
default:
throw new IllegalArgumentException("Illegal material type: " + type);
}
-
- Material bestMatch = null;
-
- // Alter the search mechanism to handle older specifications.
- // If a key is specified, then we match on key, if one is found.
- // Otherwise we return the material which matches on name.
- // this requires us to loop through the entire db at least once to look for the key.
+
+ String name = trans.get("material", baseName);
+
for (Material m : db) {
- // perfect match based on key.
- if ( key != null && m.getKey().equals(key) ) {
- // Exact match
- if ( MathUtil.equals(m.getDensity(), density) ) {
- return m;
- }
- // Custom material with standard name
- return Material.newUserMaterialWithKey(type, key, m.getName(), density);
- }
if (m.getName().equalsIgnoreCase(name) && MathUtil.equals(m.getDensity(), density)) {
- bestMatch = m;
+ return m;
}
}
- if ( bestMatch != null ) {
- return bestMatch;
- }
- return Material.newUserMaterial(type, name, density);
+ return Material.newMaterial(type, name, density, true);
}
-
-
+
}
import net.sf.openrocket.rocketcomponent.Transition;
import net.sf.openrocket.rocketcomponent.TrapezoidFinSet;
import net.sf.openrocket.rocketcomponent.TubeCoupler;
-import net.sf.openrocket.simulation.customexpression.CustomExpression;
import net.sf.openrocket.simulation.FlightData;
import net.sf.openrocket.simulation.FlightDataBranch;
import net.sf.openrocket.simulation.FlightDataType;
import net.sf.openrocket.simulation.FlightEvent;
import net.sf.openrocket.simulation.FlightEvent.Type;
import net.sf.openrocket.simulation.SimulationOptions;
+import net.sf.openrocket.simulation.customexpression.CustomExpression;
import net.sf.openrocket.startup.Application;
import net.sf.openrocket.unit.UnitGroup;
import net.sf.openrocket.util.BugException;
*/
public class OpenRocketLoader extends AbstractRocketLoader {
private static final LogHelper log = Application.getLogger();
-
-
+
+
@Override
public OpenRocketDocument loadFromStream(InputStream source, MotorFinder motorFinder) throws RocketLoadException,
- IOException {
+ IOException {
log.info("Loading .ork file");
DocumentLoadingContext context = new DocumentLoadingContext();
context.setMotorFinder(motorFinder);
-
+
InputSource xmlSource = new InputSource(source);
OpenRocketHandler handler = new OpenRocketHandler(context);
-
-
+
+
try {
SimpleSAX.readXML(xmlSource, handler, warnings);
} catch (SAXException e) {
log.warn("Malformed XML in input");
throw new RocketLoadException("Malformed XML in input.", e);
}
-
-
+
+
OpenRocketDocument doc = handler.getDocument();
doc.getDefaultConfiguration().setAllStages();
-
+
// Deduce suitable time skip
double timeSkip = StorageOptions.SIMULATION_DATA_NONE;
for (Simulation s : doc.getSimulations()) {
List<Double> list = branch.get(FlightDataType.TYPE_TIME);
if (list == null)
continue;
-
+
double previousTime = Double.NaN;
for (double time : list) {
if (time - previousTime < timeSkip)
}
// Round value
timeSkip = Math.rint(timeSkip * 100) / 100;
-
+
doc.getDefaultStorageOptions().setSimulationTimeSkip(timeSkip);
doc.getDefaultStorageOptions().setCompressionEnabled(false); // Set by caller if compressed
doc.getDefaultStorageOptions().setExplicitlySet(false);
-
+
doc.clearUndo();
log.info("Loading done");
return doc;
}
-
+
}
class DocumentConfig {
-
+
/* Remember to update OpenRocketSaver as well! */
public static final String[] SUPPORTED_VERSIONS = { "1.0", "1.1", "1.2", "1.3", "1.4", "1.5" };
-
+
/**
* Divisor used in converting an integer version to the point-represented version.
* The integer version divided by this value is the major version and the remainder is
* the minor version. For example 101 corresponds to file version "1.1".
*/
public static final int FILE_VERSION_DIVISOR = 100;
-
-
+
+
//////// Component constructors
static final HashMap<String, Constructor<? extends RocketComponent>> constructors = new HashMap<String, Constructor<? extends RocketComponent>>();
static {
constructors.put("ellipticalfinset", EllipticalFinSet.class.getConstructor(new Class<?>[0]));
constructors.put("freeformfinset", FreeformFinSet.class.getConstructor(new Class<?>[0]));
constructors.put("launchlug", LaunchLug.class.getConstructor(new Class<?>[0]));
-
+
// Internal components
constructors.put("engineblock", EngineBlock.class.getConstructor(new Class<?>[0]));
constructors.put("innertube", InnerTube.class.getConstructor(new Class<?>[0]));
constructors.put("tubecoupler", TubeCoupler.class.getConstructor(new Class<?>[0]));
constructors.put("bulkhead", Bulkhead.class.getConstructor(new Class<?>[0]));
constructors.put("centeringring", CenteringRing.class.getConstructor(new Class<?>[0]));
-
+
constructors.put("masscomponent", MassComponent.class.getConstructor(new Class<?>[0]));
constructors.put("shockcord", ShockCord.class.getConstructor(new Class<?>[0]));
constructors.put("parachute", Parachute.class.getConstructor(new Class<?>[0]));
constructors.put("streamer", Streamer.class.getConstructor(new Class<?>[0]));
-
+
// Other
constructors.put("stage", Stage.class.getConstructor(new Class<?>[0]));
-
+
} catch (NoSuchMethodException e) {
throw new BugException(
"Error in constructing the 'constructors' HashMap.");
}
}
-
-
+
+
//////// Parameter setters
/*
* The keys are of the form Class:param, where Class is the class name and param
Reflection.findMethod(RocketComponent.class, "setComment", String.class)));
setters.put("RocketComponent:preset", new ComponentPresetSetter(
Reflection.findMethod(RocketComponent.class, "loadPreset", ComponentPreset.class)));
-
+
// ExternalComponent
setters.put("ExternalComponent:finish", new EnumSetter<Finish>(
Reflection.findMethod(ExternalComponent.class, "setFinish", Finish.class),
setters.put("ExternalComponent:material", new MaterialSetter(
Reflection.findMethod(ExternalComponent.class, "setMaterial", Material.class),
Material.Type.BULK));
-
+
// BodyComponent
setters.put("BodyComponent:length", new DoubleSetter(
Reflection.findMethod(BodyComponent.class, "setLength", double.class)));
-
+
// SymmetricComponent
setters.put("SymmetricComponent:thickness", new DoubleSetter(
Reflection.findMethod(SymmetricComponent.class, "setThickness", double.class),
"filled",
Reflection.findMethod(SymmetricComponent.class, "setFilled", boolean.class)));
-
+
// BodyTube
setters.put("BodyTube:radius", new DoubleSetter(
Reflection.findMethod(BodyTube.class, "setOuterRadius", double.class),
"auto",
Reflection.findMethod(BodyTube.class, "setOuterRadiusAutomatic", boolean.class)));
-
+
// Transition
setters.put("Transition:shape", new EnumSetter<Transition.Shape>(
Reflection.findMethod(Transition.class, "setType", Transition.Shape.class),
Reflection.findMethod(Transition.class, "setClipped", boolean.class)));
setters.put("Transition:shapeparameter", new DoubleSetter(
Reflection.findMethod(Transition.class, "setShapeParameter", double.class)));
-
+
setters.put("Transition:foreradius", new DoubleSetter(
Reflection.findMethod(Transition.class, "setForeRadius", double.class),
"auto",
Reflection.findMethod(Transition.class, "setAftRadius", double.class),
"auto",
Reflection.findMethod(Transition.class, "setAftRadiusAutomatic", boolean.class)));
-
+
setters.put("Transition:foreshoulderradius", new DoubleSetter(
Reflection.findMethod(Transition.class, "setForeShoulderRadius", double.class)));
setters.put("Transition:foreshoulderlength", new DoubleSetter(
Reflection.findMethod(Transition.class, "setForeShoulderThickness", double.class)));
setters.put("Transition:foreshouldercapped", new BooleanSetter(
Reflection.findMethod(Transition.class, "setForeShoulderCapped", boolean.class)));
-
+
setters.put("Transition:aftshoulderradius", new DoubleSetter(
Reflection.findMethod(Transition.class, "setAftShoulderRadius", double.class)));
setters.put("Transition:aftshoulderlength", new DoubleSetter(
Reflection.findMethod(Transition.class, "setAftShoulderThickness", double.class)));
setters.put("Transition:aftshouldercapped", new BooleanSetter(
Reflection.findMethod(Transition.class, "setAftShoulderCapped", boolean.class)));
-
+
// NoseCone - disable disallowed elements
setters.put("NoseCone:foreradius", null);
setters.put("NoseCone:foreshoulderradius", null);
setters.put("NoseCone:foreshoulderlength", null);
setters.put("NoseCone:foreshoulderthickness", null);
setters.put("NoseCone:foreshouldercapped", null);
-
+
// FinSet
setters.put("FinSet:fincount", new IntSetter(
Reflection.findMethod(FinSet.class, "setFinCount", int.class)));
setters.put("FinSet:tablength", new DoubleSetter(
Reflection.findMethod(FinSet.class, "setTabLength", double.class)));
setters.put("FinSet:tabposition", new FinTabPositionSetter());
-
+
// TrapezoidFinSet
setters.put("TrapezoidFinSet:rootchord", new DoubleSetter(
Reflection.findMethod(TrapezoidFinSet.class, "setRootChord", double.class)));
Reflection.findMethod(TrapezoidFinSet.class, "setSweep", double.class)));
setters.put("TrapezoidFinSet:height", new DoubleSetter(
Reflection.findMethod(TrapezoidFinSet.class, "setHeight", double.class)));
-
+
// EllipticalFinSet
setters.put("EllipticalFinSet:rootchord", new DoubleSetter(
Reflection.findMethod(EllipticalFinSet.class, "setLength", double.class)));
setters.put("EllipticalFinSet:height", new DoubleSetter(
Reflection.findMethod(EllipticalFinSet.class, "setHeight", double.class)));
-
+
// FreeformFinSet points handled as a special handler
-
+
// LaunchLug
setters.put("LaunchLug:radius", new DoubleSetter(
Reflection.findMethod(LaunchLug.class, "setOuterRadius", double.class)));
setters.put("LaunchLug:radialdirection", new DoubleSetter(
Reflection.findMethod(LaunchLug.class, "setRadialDirection", double.class),
Math.PI / 180.0));
-
+
// InternalComponent - nothing
-
+
// StructuralComponent
setters.put("StructuralComponent:material", new MaterialSetter(
Reflection.findMethod(StructuralComponent.class, "setMaterial", Material.class),
Material.Type.BULK));
-
+
// RingComponent
setters.put("RingComponent:length", new DoubleSetter(
Reflection.findMethod(RingComponent.class, "setLength", double.class)));
setters.put("RingComponent:radialdirection", new DoubleSetter(
Reflection.findMethod(RingComponent.class, "setRadialDirection", double.class),
Math.PI / 180.0));
-
+
// ThicknessRingComponent - radius on separate components due to differing automatics
setters.put("ThicknessRingComponent:thickness", new DoubleSetter(
Reflection.findMethod(ThicknessRingComponent.class, "setThickness", double.class)));
-
+
// EngineBlock
setters.put("EngineBlock:outerradius", new DoubleSetter(
Reflection.findMethod(EngineBlock.class, "setOuterRadius", double.class),
"auto",
Reflection.findMethod(EngineBlock.class, "setOuterRadiusAutomatic", boolean.class)));
-
+
// TubeCoupler
setters.put("TubeCoupler:outerradius", new DoubleSetter(
Reflection.findMethod(TubeCoupler.class, "setOuterRadius", double.class),
"auto",
Reflection.findMethod(TubeCoupler.class, "setOuterRadiusAutomatic", boolean.class)));
-
+
// InnerTube
setters.put("InnerTube:outerradius", new DoubleSetter(
Reflection.findMethod(InnerTube.class, "setOuterRadius", double.class)));
setters.put("InnerTube:clusterrotation", new DoubleSetter(
Reflection.findMethod(InnerTube.class, "setClusterRotation", double.class),
Math.PI / 180.0));
-
+
// RadiusRingComponent
-
+
// Bulkhead
setters.put("RadiusRingComponent:innerradius", new DoubleSetter(
Reflection.findMethod(RadiusRingComponent.class, "setInnerRadius", double.class)));
Reflection.findMethod(Bulkhead.class, "setOuterRadius", double.class),
"auto",
Reflection.findMethod(Bulkhead.class, "setOuterRadiusAutomatic", boolean.class)));
-
+
// CenteringRing
setters.put("CenteringRing:innerradius", new DoubleSetter(
Reflection.findMethod(CenteringRing.class, "setInnerRadius", double.class),
Reflection.findMethod(CenteringRing.class, "setOuterRadius", double.class),
"auto",
Reflection.findMethod(CenteringRing.class, "setOuterRadiusAutomatic", boolean.class)));
-
-
+
+
// MassObject
setters.put("MassObject:packedlength", new DoubleSetter(
Reflection.findMethod(MassObject.class, "setLength", double.class)));
setters.put("MassObject:radialdirection", new DoubleSetter(
Reflection.findMethod(MassObject.class, "setRadialDirection", double.class),
Math.PI / 180.0));
-
+
// MassComponent
setters.put("MassComponent:mass", new DoubleSetter(
Reflection.findMethod(MassComponent.class, "setComponentMass", double.class)));
-
+
// ShockCord
setters.put("ShockCord:cordlength", new DoubleSetter(
Reflection.findMethod(ShockCord.class, "setCordLength", double.class)));
setters.put("ShockCord:material", new MaterialSetter(
Reflection.findMethod(ShockCord.class, "setMaterial", Material.class),
Material.Type.LINE));
-
+
// RecoveryDevice
setters.put("RecoveryDevice:cd", new DoubleSetter(
Reflection.findMethod(RecoveryDevice.class, "setCD", double.class),
setters.put("RecoveryDevice:material", new MaterialSetter(
Reflection.findMethod(RecoveryDevice.class, "setMaterial", Material.class),
Material.Type.SURFACE));
-
+
// Parachute
setters.put("Parachute:diameter", new DoubleSetter(
Reflection.findMethod(Parachute.class, "setDiameter", double.class)));
setters.put("Parachute:linematerial", new MaterialSetter(
Reflection.findMethod(Parachute.class, "setLineMaterial", Material.class),
Material.Type.LINE));
-
+
// Streamer
setters.put("Streamer:striplength", new DoubleSetter(
Reflection.findMethod(Streamer.class, "setStripLength", double.class)));
setters.put("Streamer:stripwidth", new DoubleSetter(
Reflection.findMethod(Streamer.class, "setStripWidth", double.class)));
-
+
// Rocket
// <motorconfiguration> handled by separate handler
setters.put("Rocket:referencetype", new EnumSetter<ReferenceType>(
Reflection.findMethod(Rocket.class, "setDesigner", String.class)));
setters.put("Rocket:revision", new StringSetter(
Reflection.findMethod(Rocket.class, "setRevision", String.class)));
-
+
// Stage
setters.put("Stage:separationevent", new EnumSetter<Stage.SeparationEvent>(
Reflection.findMethod(Stage.class, "setSeparationEvent", Stage.SeparationEvent.class),
Stage.SeparationEvent.class));
setters.put("Stage:separationdelay", new DoubleSetter(
Reflection.findMethod(Stage.class, "setSeparationDelay", double.class)));
-
+
}
-
-
+
+
/**
* Search for a enum value that has the corresponding name as an XML value. The current
* conversion from enum name to XML value is to lowercase the name and strip out all
*/
public static <T extends Enum<T>> Enum<T> findEnum(String name,
Class<? extends Enum<T>> enumClass) {
-
+
if (name == null)
return null;
name = name.trim();
}
return null;
}
-
-
+
+
/**
* Convert a string to a double including formatting specifications of the OpenRocket
* file format. This accepts all formatting that is valid for
class OpenRocketHandler extends AbstractElementHandler {
private final DocumentLoadingContext context;
private OpenRocketContentHandler handler = null;
-
+
public OpenRocketHandler(DocumentLoadingContext context) {
this.context = context;
}
-
+
/**
* Return the OpenRocketDocument read from the file, or <code>null</code> if a document
* has not been read yet.
public OpenRocketDocument getDocument() {
return handler.getDocument();
}
-
+
@Override
public ElementHandler openElement(String element, HashMap<String, String> attributes,
WarningSet warnings) {
-
+
// Check for unknown elements
if (!element.equals("openrocket")) {
warnings.add(Warning.fromString("Unknown element " + element + ", ignoring."));
return null;
}
-
+
// Check for first call
if (handler != null) {
warnings.add(Warning.fromString("Multiple document elements found, ignoring later "
+ "ones."));
return null;
}
-
+
// Check version number
String version = null;
String creator = attributes.remove("creator");
str += ", attempting to read file anyway.";
warnings.add(str);
}
-
+
context.setFileVersion(parseVersion(docVersion));
-
+
handler = new OpenRocketContentHandler(context);
return handler;
}
-
-
+
+
private int parseVersion(String docVersion) {
if (docVersion == null)
return 0;
-
+
Matcher m = Pattern.compile("^([0-9]+)\\.([0-9]+)$").matcher(docVersion);
if (m.matches()) {
int major = Integer.parseInt(m.group(1));
return 0;
}
}
-
+
@Override
public void closeElement(String element, HashMap<String, String> attributes,
String content, WarningSet warnings) throws SAXException {
attributes.remove("creator");
super.closeElement(element, attributes, content, warnings);
}
-
-
+
+
}
private final DocumentLoadingContext context;
private final OpenRocketDocument doc;
private final Rocket rocket;
-
+
private boolean rocketDefined = false;
private boolean simulationsDefined = false;
private boolean datatypesDefined = false;
-
+
public OpenRocketContentHandler(DocumentLoadingContext context) {
this.context = context;
this.rocket = new Rocket();
this.doc = new OpenRocketDocument(rocket);
}
-
+
public OpenRocketDocument getDocument() {
if (!rocketDefined)
return null;
return doc;
}
-
+
@Override
public ElementHandler openElement(String element, HashMap<String, String> attributes,
WarningSet warnings) {
-
+
if (element.equals("rocket")) {
if (rocketDefined) {
warnings.add(Warning
return new ComponentParameterHandler(rocket, context);
}
- if (element.equals("datatypes")){
+ if (element.equals("datatypes")) {
if (datatypesDefined) {
warnings.add(Warning.fromString("Multiple datatype blocks. Ignoring later ones."));
return null;
datatypesDefined = true;
return new DatatypeHandler(this, context);
}
-
+
if (element.equals("simulations")) {
if (simulationsDefined) {
warnings.add(Warning
simulationsDefined = true;
return new SimulationsHandler(doc, context);
}
-
+
warnings.add(Warning.fromString("Unknown element " + element + ", ignoring."));
-
+
return null;
}
}
HashMap<String, String> attributes, WarningSet warnings)
throws SAXException {
- if (element.equals("type") && attributes.get("source").equals("customexpression") ){
+ if (element.equals("type") && attributes.get("source").equals("customexpression")) {
customExpressionHandler = new CustomExpressionHandler(contentHandler, context);
return customExpressionHandler;
}
attributes.remove("source");
super.closeElement(element, attributes, content, warnings);
- if (customExpressionHandler != null){
+ if (customExpressionHandler != null) {
contentHandler.getDocument().addCustomExpression(customExpressionHandler.currentExpression);
}
}
-class CustomExpressionHandler extends AbstractElementHandler{
+class CustomExpressionHandler extends AbstractElementHandler {
private final DocumentLoadingContext context;
private final OpenRocketContentHandler contentHandler;
public CustomExpression currentExpression;
this.context = context;
this.contentHandler = contentHandler;
currentExpression = new CustomExpression(contentHandler.getDocument());
-
+
}
@Override
public ElementHandler openElement(String element,
HashMap<String, String> attributes, WarningSet warnings)
throws SAXException {
-
+
return this;
}
@Override
public void closeElement(String element, HashMap<String, String> attributes,
- String content, WarningSet warnings) throws SAXException {
-
+ String content, WarningSet warnings) throws SAXException {
+
if (element.equals("type")) {
contentHandler.getDocument().addCustomExpression(currentExpression);
}
-
+
if (element.equals("name")) {
currentExpression.setName(content);
}
-
+
if (element.equals("symbol")) {
currentExpression.setSymbol(content);
}
currentExpression.setUnit(content);
}
- if (element.equals("expression")){
+ if (element.equals("expression")) {
currentExpression.setExpression(content);
}
- }
+ }
}
/**
class ComponentHandler extends AbstractElementHandler {
private final DocumentLoadingContext context;
private final RocketComponent parent;
-
+
public ComponentHandler(RocketComponent parent, DocumentLoadingContext context) {
this.parent = parent;
this.context = context;
}
-
+
@Override
public ElementHandler openElement(String element, HashMap<String, String> attributes,
WarningSet warnings) {
-
+
// Attempt to construct new component
Constructor<? extends RocketComponent> constructor = DocumentConfig.constructors
.get(element);
warnings.add(Warning.fromString("Unknown element " + element + ", ignoring."));
return null;
}
-
+
RocketComponent c;
try {
c = constructor.newInstance();
} catch (InvocationTargetException e) {
throw Reflection.handleWrappedException(e);
}
-
+
parent.addChild(c);
-
+
return new ComponentParameterHandler(c, context);
}
}
class ComponentParameterHandler extends AbstractElementHandler {
private final DocumentLoadingContext context;
private final RocketComponent component;
-
+
public ComponentParameterHandler(RocketComponent c, DocumentLoadingContext context) {
this.component = c;
this.context = context;
}
-
+
@Override
public ElementHandler openElement(String element, HashMap<String, String> attributes,
WarningSet warnings) {
-
+
// Check for specific elements that contain other elements
if (element.equals("subcomponents")) {
return new ComponentHandler(component, context);
}
return new MotorConfigurationHandler((Rocket) component, context);
}
-
-
+
+
return PlainTextHandler.INSTANCE;
}
-
+
@Override
public void closeElement(String element, HashMap<String, String> attributes,
String content, WarningSet warnings) {
-
+
if (element.equals("subcomponents") || element.equals("motormount") ||
element.equals("finpoints") || element.equals("motorconfiguration")) {
return;
}
-
+
// Search for the correct setter class
-
+
Class<?> c;
for (c = component.getClass(); c != null; c = c.getSuperclass()) {
String setterKey = c.getSimpleName() + ":" + element;
private final DocumentLoadingContext context;
private final FreeformFinSet finset;
private final ArrayList<Coordinate> coordinates = new ArrayList<Coordinate>();
-
+
public FinSetPointHandler(FreeformFinSet finset, DocumentLoadingContext context) {
this.finset = finset;
this.context = context;
}
-
+
@Override
public ElementHandler openElement(String element, HashMap<String, String> attributes,
WarningSet warnings) {
return PlainTextHandler.INSTANCE;
}
-
-
+
+
@Override
public void closeElement(String element, HashMap<String, String> attributes,
String content, WarningSet warnings) throws SAXException {
-
+
String strx = attributes.remove("x");
String stry = attributes.remove("y");
if (strx == null || stry == null) {
warnings.add(Warning.fromString("Illegal fin points specification, ignoring."));
return;
}
-
+
super.closeElement(element, attributes, content, warnings);
}
-
+
@Override
public void endHandler(String element, HashMap<String, String> attributes,
String content, WarningSet warnings) {
private final DocumentLoadingContext context;
private final MotorMount mount;
private MotorHandler motorHandler;
-
+
public MotorMountHandler(MotorMount mount, DocumentLoadingContext context) {
this.mount = mount;
this.context = context;
mount.setMotorMount(true);
}
-
+
@Override
public ElementHandler openElement(String element, HashMap<String, String> attributes,
WarningSet warnings) {
-
+
if (element.equals("motor")) {
motorHandler = new MotorHandler(context);
return motorHandler;
}
-
+
if (element.equals("ignitionevent") ||
element.equals("ignitiondelay") ||
element.equals("overhang")) {
return PlainTextHandler.INSTANCE;
}
-
+
warnings.add(Warning.fromString("Unknown element '" + element + "' encountered, ignoring."));
return null;
}
-
-
-
+
+
+
@Override
public void closeElement(String element, HashMap<String, String> attributes,
String content, WarningSet warnings) throws SAXException {
-
+
if (element.equals("motor")) {
String id = attributes.get("configid");
if (id == null || id.equals("")) {
warnings.add(Warning.fromString("Illegal motor specification, ignoring."));
return;
}
-
+
Motor motor = motorHandler.getMotor(warnings);
mount.setMotor(id, motor);
mount.setMotorDelay(id, motorHandler.getDelay(warnings));
return;
}
-
+
if (element.equals("ignitionevent")) {
MotorMount.IgnitionEvent event = null;
for (MotorMount.IgnitionEvent e : MotorMount.IgnitionEvent.values()) {
mount.setIgnitionEvent(event);
return;
}
-
+
if (element.equals("ignitiondelay")) {
double d;
try {
mount.setIgnitionDelay(d);
return;
}
-
+
if (element.equals("overhang")) {
double d;
try {
mount.setMotorOverhang(d);
return;
}
-
+
super.closeElement(element, attributes, content, warnings);
}
}
private final Rocket rocket;
private String name = null;
private boolean inNameElement = false;
-
+
public MotorConfigurationHandler(Rocket rocket, DocumentLoadingContext context) {
this.rocket = rocket;
this.context = context;
}
-
+
@Override
public ElementHandler openElement(String element, HashMap<String, String> attributes,
WarningSet warnings) {
-
+
if (inNameElement || !element.equals("name")) {
warnings.add(Warning.FILE_INVALID_PARAMETER);
return null;
}
inNameElement = true;
-
+
return PlainTextHandler.INSTANCE;
}
-
+
@Override
public void closeElement(String element, HashMap<String, String> attributes,
String content, WarningSet warnings) {
name = content;
}
-
+
@Override
public void endHandler(String element, HashMap<String, String> attributes,
String content, WarningSet warnings) throws SAXException {
-
+
String configid = attributes.remove("configid");
if (configid == null || configid.equals("")) {
warnings.add(Warning.FILE_INVALID_PARAMETER);
return;
}
-
+
if (!rocket.addMotorConfigurationID(configid)) {
warnings.add("Duplicate motor configuration ID used.");
return;
}
-
+
if (name != null && name.trim().length() > 0) {
rocket.setMotorConfigurationName(configid, name);
}
-
+
if ("true".equals(attributes.remove("default"))) {
rocket.getDefaultConfiguration().setMotorConfigurationID(configid);
}
-
+
super.closeElement(element, attributes, content, warnings);
}
}
class MotorHandler extends AbstractElementHandler {
/** File version where latest digest format was introduced */
private static final int MOTOR_DIGEST_VERSION = 104;
-
+
private final DocumentLoadingContext context;
private Motor.Type type = null;
private String manufacturer = null;
private double diameter = Double.NaN;
private double length = Double.NaN;
private double delay = Double.NaN;
-
+
public MotorHandler(DocumentLoadingContext context) {
this.context = context;
}
-
-
+
+
@Override
public ElementHandler openElement(String element, HashMap<String, String> attributes,
WarningSet warnings) {
return PlainTextHandler.INSTANCE;
}
-
-
+
+
/**
* Return the motor to use, or null.
*/
public Motor getMotor(WarningSet warnings) {
return context.getMotorFinder().findMotor(type, manufacturer, designation, diameter, length, digest, warnings);
}
-
+
/**
* Return the delay to use for the motor.
*/
}
return delay;
}
-
-
+
+
@Override
public void closeElement(String element, HashMap<String, String> attributes,
String content, WarningSet warnings) throws SAXException {
-
+
content = content.trim();
-
+
if (element.equals("type")) {
-
+
// Motor type
type = null;
for (Motor.Type t : Motor.Type.values()) {
if (type == null) {
warnings.add(Warning.fromString("Unknown motor type '" + content + "', ignoring."));
}
-
+
} else if (element.equals("manufacturer")) {
-
+
// Manufacturer
manufacturer = content.trim();
-
+
} else if (element.equals("designation")) {
-
+
// Designation
designation = content.trim();
-
+
} else if (element.equals("digest")) {
-
+
// Digest is used only for file versions saved using the same digest algorithm
if (context.getFileVersion() >= MOTOR_DIGEST_VERSION) {
digest = content.trim();
}
-
+
} else if (element.equals("diameter")) {
-
+
// Diameter
diameter = Double.NaN;
try {
if (Double.isNaN(diameter)) {
warnings.add(Warning.fromString("Illegal motor diameter specified, ignoring."));
}
-
+
} else if (element.equals("length")) {
-
+
// Length
length = Double.NaN;
try {
length = Double.parseDouble(content.trim());
} catch (NumberFormatException ignore) {
}
-
+
if (Double.isNaN(length)) {
warnings.add(Warning.fromString("Illegal motor diameter specified, ignoring."));
}
-
+
} else if (element.equals("delay")) {
-
+
// Delay
delay = Double.NaN;
if (content.equals("none")) {
delay = Double.parseDouble(content.trim());
} catch (NumberFormatException ignore) {
}
-
+
if (Double.isNaN(delay)) {
warnings.add(Warning.fromString("Illegal motor delay specified, ignoring."));
}
-
+
}
-
+
} else {
super.closeElement(element, attributes, content, warnings);
}
}
-
+
}
private final DocumentLoadingContext context;
private final OpenRocketDocument doc;
private SingleSimulationHandler handler;
-
+
public SimulationsHandler(OpenRocketDocument doc, DocumentLoadingContext context) {
this.doc = doc;
this.context = context;
}
-
+
@Override
public ElementHandler openElement(String element, HashMap<String, String> attributes,
WarningSet warnings) {
-
+
if (!element.equals("simulation")) {
warnings.add("Unknown element '" + element + "', ignoring.");
return null;
}
-
+
handler = new SingleSimulationHandler(doc, context);
return handler;
}
-
+
@Override
public void closeElement(String element, HashMap<String, String> attributes,
String content, WarningSet warnings) throws SAXException {
attributes.remove("status");
super.closeElement(element, attributes, content, warnings);
}
-
-
+
+
}
class SingleSimulationHandler extends AbstractElementHandler {
-
+
private final DocumentLoadingContext context;
-
+
private final OpenRocketDocument doc;
-
+
private String name;
-
+
private SimulationConditionsHandler conditionHandler;
private FlightDataHandler dataHandler;
private final List<String> listeners = new ArrayList<String>();
-
+
public SingleSimulationHandler(OpenRocketDocument doc, DocumentLoadingContext context) {
this.doc = doc;
this.context = context;
}
-
- public OpenRocketDocument getDocument(){
+
+ public OpenRocketDocument getDocument() {
return doc;
}
@Override
public ElementHandler openElement(String element, HashMap<String, String> attributes,
WarningSet warnings) {
-
+
if (element.equals("name") || element.equals("simulator") ||
element.equals("calculator") || element.equals("listener")) {
return PlainTextHandler.INSTANCE;
return null;
}
}
-
+
@Override
public void closeElement(String element, HashMap<String, String> attributes,
String content, WarningSet warnings) {
-
+
if (element.equals("name")) {
name = content;
} else if (element.equals("simulator")) {
} else if (element.equals("listener") && content.trim().length() > 0) {
listeners.add(content.trim());
}
-
+
}
-
+
@Override
public void endHandler(String element, HashMap<String, String> attributes,
String content, WarningSet warnings) {
-
+
String s = attributes.get("status");
Simulation.Status status = (Status) DocumentConfig.findEnum(s, Simulation.Status.class);
if (status == null) {
warnings.add("Simulation status unknown, assuming outdated.");
status = Simulation.Status.OUTDATED;
}
-
+
SimulationOptions conditions;
if (conditionHandler != null) {
conditions = conditionHandler.getConditions();
warnings.add("Simulation conditions not defined, using defaults.");
conditions = new SimulationOptions(doc.getRocket());
}
-
+
if (name == null)
name = "Simulation";
-
+
FlightData data;
if (dataHandler == null)
data = null;
else
data = dataHandler.getFlightData();
-
+
Simulation simulation = new Simulation(doc.getRocket(), status, name,
conditions, listeners, data);
-
+
doc.addSimulation(simulation);
}
}
-
+
class SimulationConditionsHandler extends AbstractElementHandler {
private final DocumentLoadingContext context;
private SimulationOptions conditions;
private AtmosphereHandler atmosphereHandler;
-
+
public SimulationConditionsHandler(Rocket rocket, DocumentLoadingContext context) {
this.context = context;
conditions = new SimulationOptions(rocket);
// Set up default loading settings (which may differ from the new defaults)
conditions.setGeodeticComputation(GeodeticComputationStrategy.FLAT);
}
-
+
public SimulationOptions getConditions() {
return conditions;
}
-
+
@Override
public ElementHandler openElement(String element, HashMap<String, String> attributes,
WarningSet warnings) {
}
return PlainTextHandler.INSTANCE;
}
-
+
@Override
public void closeElement(String element, HashMap<String, String> attributes,
String content, WarningSet warnings) {
-
+
double d = Double.NaN;
try {
d = Double.parseDouble(content);
} catch (NumberFormatException ignore) {
}
-
-
+
+
if (element.equals("configid")) {
if (content.equals("")) {
conditions.setMotorConfigurationID(null);
private final String model;
private double temperature = Double.NaN;
private double pressure = Double.NaN;
-
+
public AtmosphereHandler(String model, DocumentLoadingContext context) {
this.model = model;
this.context = context;
}
-
+
@Override
public ElementHandler openElement(String element, HashMap<String, String> attributes,
WarningSet warnings) {
return PlainTextHandler.INSTANCE;
}
-
+
@Override
public void closeElement(String element, HashMap<String, String> attributes,
String content, WarningSet warnings) throws SAXException {
-
+
double d = Double.NaN;
try {
d = Double.parseDouble(content);
} catch (NumberFormatException ignore) {
}
-
+
if (element.equals("basetemperature")) {
if (Double.isNaN(d)) {
warnings.add("Illegal base temperature specified, ignoring.");
super.closeElement(element, attributes, content, warnings);
}
}
-
-
+
+
public void storeSettings(SimulationOptions cond, WarningSet warnings) {
if (!Double.isNaN(pressure)) {
cond.setLaunchPressure(pressure);
if (!Double.isNaN(temperature)) {
cond.setLaunchTemperature(temperature);
}
-
+
if ("isa".equals(model)) {
cond.setISAAtmosphere(true);
} else if ("extendedisa".equals(model)) {
warnings.add("Unknown atmospheric model, using ISA.");
}
}
-
+
}
class FlightDataHandler extends AbstractElementHandler {
private final DocumentLoadingContext context;
-
+
private FlightDataBranchHandler dataHandler;
private WarningSet warningSet = new WarningSet();
private List<FlightDataBranch> branches = new ArrayList<FlightDataBranch>();
private SingleSimulationHandler simHandler;
private FlightData data;
-
-
+
+
public FlightDataHandler(SingleSimulationHandler simHandler, DocumentLoadingContext context) {
this.context = context;
this.simHandler = simHandler;
}
-
+
public FlightData getFlightData() {
return data;
}
-
+
@Override
public ElementHandler openElement(String element, HashMap<String, String> attributes,
WarningSet warnings) {
-
+
if (element.equals("warning")) {
return PlainTextHandler.INSTANCE;
}
warnings.add("Illegal flight data definition, ignoring.");
return null;
}
- dataHandler = new FlightDataBranchHandler( attributes.get("name"),
- attributes.get("types"),
- simHandler, context);
+ dataHandler = new FlightDataBranchHandler(attributes.get("name"),
+ attributes.get("types"),
+ simHandler, context);
return dataHandler;
}
-
+
warnings.add("Unknown element '" + element + "' encountered, ignoring.");
return null;
}
-
-
+
+
@Override
public void closeElement(String element, HashMap<String, String> attributes,
String content, WarningSet warnings) {
-
+
if (element.equals("databranch")) {
FlightDataBranch branch = dataHandler.getBranch();
if (branch.getLength() > 0) {
warningSet.add(Warning.fromString(content));
}
}
-
-
+
+
@Override
public void endHandler(String element, HashMap<String, String> attributes,
String content, WarningSet warnings) {
-
+
if (branches.size() > 0) {
data = new FlightData(branches.toArray(new FlightDataBranch[0]));
} else {
double groundHitVelocity = Double.NaN;
double launchRodVelocity = Double.NaN;
double deploymentVelocity = Double.NaN;
-
+
try {
maxAltitude = DocumentConfig.stringToDouble(attributes.get("maxaltitude"));
} catch (NumberFormatException ignore) {
deploymentVelocity = DocumentConfig.stringToDouble(attributes.get("deploymentvelocity"));
} catch (NumberFormatException ignore) {
}
-
+
data = new FlightData(maxAltitude, maxVelocity, maxAcceleration, maxMach,
timeToApogee, flightTime, groundHitVelocity, launchRodVelocity, deploymentVelocity);
}
-
+
data.getWarningSet().addAll(warningSet);
data.immute();
}
-
-
+
+
}
types[i] = matching;
//types[i] = FlightDataType.getType(typeName, matching.getSymbol(), matching.getUnitGroup());
}
-
+
// TODO: LOW: May throw an IllegalArgumentException
branch = new FlightDataBranch(name, types);
}
// Find the full flight data type given name only
// Note: this way of doing it requires that custom expressions always come before flight data in the file,
// not the nicest but this is always the case anyway.
- private FlightDataType findFlightDataType(String name){
+ private FlightDataType findFlightDataType(String name) {
- // Kevins version with lookup by key. Not using right now
+ // Kevins version with lookup by key. Not using right now
/*
if ( key != null ) {
for (FlightDataType t : FlightDataType.ALL_TYPES){
}
}
*/
-
+
// Look in built in types
- for (FlightDataType t : FlightDataType.ALL_TYPES){
- if (t.getName().equals(name) ){
+ for (FlightDataType t : FlightDataType.ALL_TYPES) {
+ if (t.getName().equals(name)) {
return t;
}
}
// Look in custom expressions
- for (CustomExpression exp : simHandler.getDocument().getCustomExpressions()){
- if (exp.getName().equals(name) ){
+ for (CustomExpression exp : simHandler.getDocument().getCustomExpressions()) {
+ if (exp.getName().equals(name)) {
return exp.getType();
}
}
- log.warn("Could not find the flight data type '"+name+"' used in the XML file. Substituted type with unknown symbol and units.");
+ log.warn("Could not find the flight data type '" + name + "' used in the XML file. Substituted type with unknown symbol and units.");
return FlightDataType.getType(name, "Unknown", UnitGroup.UNITS_NONE);
}
-
+
public FlightDataBranch getBranch() {
branch.immute();
return branch;
}
-
+
@Override
public ElementHandler openElement(String element, HashMap<String, String> attributes,
WarningSet warnings) {
-
+
if (element.equals("datapoint"))
return PlainTextHandler.INSTANCE;
if (element.equals("event"))
return PlainTextHandler.INSTANCE;
-
+
warnings.add("Unknown element '" + element + "' encountered, ignoring.");
return null;
}
-
-
+
+
@Override
public void closeElement(String element, HashMap<String, String> attributes,
String content, WarningSet warnings) {
-
+
if (element.equals("event")) {
double time;
FlightEvent.Type type;
-
+
try {
time = DocumentConfig.stringToDouble(attributes.get("time"));
} catch (NumberFormatException e) {
warnings.add("Illegal event specification, ignoring.");
return;
}
-
+
type = (Type) DocumentConfig.findEnum(attributes.get("type"), FlightEvent.Type.class);
if (type == null) {
warnings.add("Illegal event specification, ignoring.");
return;
}
-
+
branch.addEvent(new FlightEvent(type, time));
return;
}
-
+
if (!element.equals("datapoint")) {
warnings.add("Unknown element '" + element + "' encountered, ignoring.");
return;
}
-
+
// element == "datapoint"
-
-
+
+
// Check line format
String[] split = content.split(",");
if (split.length != types.length) {
warnings.add("Data point did not contain correct amount of values, ignoring point.");
return;
}
-
+
// Parse the doubles
double[] values = new double[split.length];
for (int i = 0; i < values.length; i++) {
return;
}
}
-
+
// Add point to branch
branch.addPoint();
for (int i = 0; i < types.length; i++) {
//// StringSetter - sets the value to the contained String
class StringSetter implements Setter {
private final Reflection.Method setMethod;
-
+
public StringSetter(Reflection.Method set) {
setMethod = set;
}
-
+
@Override
public void set(RocketComponent c, String s, HashMap<String, String> attributes,
WarningSet warnings) {
//// IntSetter - set an integer value
class IntSetter implements Setter {
private final Reflection.Method setMethod;
-
+
public IntSetter(Reflection.Method set) {
setMethod = set;
}
-
+
@Override
public void set(RocketComponent c, String s, HashMap<String, String> attributes,
WarningSet warnings) {
//// BooleanSetter - set a boolean value
class BooleanSetter implements Setter {
private final Reflection.Method setMethod;
-
+
public BooleanSetter(Reflection.Method set) {
setMethod = set;
}
-
+
@Override
public void set(RocketComponent c, String s, HashMap<String, String> attributes,
WarningSet warnings) {
-
+
s = s.trim();
if (s.equalsIgnoreCase("true")) {
setMethod.invoke(c, true);
private final String specialString;
private final Reflection.Method specialMethod;
private final double multiplier;
-
+
/**
* Set only the double value.
* @param set set method for the double value.
this.specialMethod = null;
this.multiplier = 1.0;
}
-
+
/**
* Multiply with the given multiplier and set the double value.
* @param set set method for the double value.
this.specialMethod = null;
this.multiplier = mul;
}
-
+
/**
* Set the double value, or if the value equals the special string, use the
* special setter and set it to true.
this.specialMethod = specialMethod;
this.multiplier = 1.0;
}
-
-
+
+
@Override
public void set(RocketComponent c, String s, HashMap<String, String> attributes,
WarningSet warnings) {
-
+
s = s.trim();
-
+
// Check for special case
if (specialMethod != null && s.equalsIgnoreCase(specialString)) {
specialMethod.invoke(c, true);
return;
}
-
+
// Normal case
try {
double d = Double.parseDouble(s);
class OverrideSetter implements Setter {
private final Reflection.Method setMethod;
private final Reflection.Method enabledMethod;
-
+
public OverrideSetter(Reflection.Method set, Reflection.Method enabledMethod) {
this.setMethod = set;
this.enabledMethod = enabledMethod;
}
-
+
@Override
public void set(RocketComponent c, String s, HashMap<String, String> attributes,
WarningSet warnings) {
-
+
try {
double d = Double.parseDouble(s);
setMethod.invoke(c, d);
class EnumSetter<T extends Enum<T>> implements Setter {
private final Reflection.Method setter;
private final Class<T> enumClass;
-
+
public EnumSetter(Reflection.Method set, Class<T> enumClass) {
this.setter = set;
this.enumClass = enumClass;
}
-
+
@Override
public void set(RocketComponent c, String name, HashMap<String, String> attributes,
WarningSet warnings) {
-
+
Enum<?> setEnum = DocumentConfig.findEnum(name, enumClass);
if (setEnum == null) {
warnings.add(Warning.FILE_INVALID_PARAMETER);
return;
}
-
+
setter.invoke(c, setEnum);
}
}
//// ColorSetter - sets a Color value
class ColorSetter implements Setter {
private final Reflection.Method setMethod;
-
+
public ColorSetter(Reflection.Method set) {
setMethod = set;
}
-
+
@Override
public void set(RocketComponent c, String s, HashMap<String, String> attributes,
WarningSet warnings) {
-
+
String red = attributes.get("red");
String green = attributes.get("green");
String blue = attributes.get("blue");
-
+
if (red == null || green == null || blue == null) {
warnings.add(Warning.FILE_INVALID_PARAMETER);
return;
}
-
+
int r, g, b;
try {
r = Integer.parseInt(red);
warnings.add(Warning.FILE_INVALID_PARAMETER);
return;
}
-
+
if (r < 0 || g < 0 || b < 0 || r > 255 || g > 255 || b > 255) {
warnings.add(Warning.FILE_INVALID_PARAMETER);
return;
}
-
+
Color color = new Color(r, g, b);
setMethod.invoke(c, color);
-
+
if (!s.trim().equals("")) {
warnings.add(Warning.FILE_INVALID_PARAMETER);
}
////ComponentPresetSetter - sets a ComponentPreset value
class ComponentPresetSetter implements Setter {
-private final Reflection.Method setMethod;
-
-public ComponentPresetSetter(Reflection.Method set) {
- this.setMethod = set;
-}
-
-@Override
-public void set(RocketComponent c, String name, HashMap<String, String> attributes,
- WarningSet warnings) {
- String manufacturerName = attributes.get("manufacturer");
- if ( manufacturerName == null ) {
- warnings.add(Warning.fromString("Invalid ComponentPreset for component " + c.getName() + ", no manufacturer specified. Ignored"));
- return;
- }
-
- String productNo = attributes.get("partno");
- if ( productNo == null ) {
- warnings.add(Warning.fromString("Invalid ComponentPreset for component " + c.getName() + ", no partno specified. Ignored"));
- return;
- }
-
- String digest = attributes.get("digest");
- if ( digest == null ) {
- warnings.add(Warning.fromString("Invalid ComponentPreset for component " + c.getName() + ", no digest specified."));
- }
-
- String type = attributes.get("type");
- if ( type == null ) {
- warnings.add(Warning.fromString("Invalid ComponentPreset for component " + c.getName() + ", no type specified."));
+ private final Reflection.Method setMethod;
+
+ public ComponentPresetSetter(Reflection.Method set) {
+ this.setMethod = set;
}
-
- List<ComponentPreset> presets = Application.getComponentPresetDao().find( manufacturerName, productNo );
-
- ComponentPreset matchingPreset = null;
-
- for( ComponentPreset preset: presets ) {
- if ( digest != null && preset.getDigest().equals(digest) ) {
- // Found one with matching digest. Take it.
- matchingPreset = preset;
- break;
+
+ @Override
+ public void set(RocketComponent c, String name, HashMap<String, String> attributes,
+ WarningSet warnings) {
+ String manufacturerName = attributes.get("manufacturer");
+ if (manufacturerName == null) {
+ warnings.add(Warning.fromString("Invalid ComponentPreset for component " + c.getName() + ", no manufacturer specified. Ignored"));
+ return;
}
- if ( type != null && preset.getType().name().equals(type) && matchingPreset != null) {
- // Found the first one with matching type.
- matchingPreset = preset;
+
+ String productNo = attributes.get("partno");
+ if (productNo == null) {
+ warnings.add(Warning.fromString("Invalid ComponentPreset for component " + c.getName() + ", no partno specified. Ignored"));
+ return;
}
+
+ String digest = attributes.get("digest");
+ if (digest == null) {
+ warnings.add(Warning.fromString("Invalid ComponentPreset for component " + c.getName() + ", no digest specified."));
+ }
+
+ String type = attributes.get("type");
+ if (type == null) {
+ warnings.add(Warning.fromString("Invalid ComponentPreset for component " + c.getName() + ", no type specified."));
+ }
+
+ List<ComponentPreset> presets = Application.getComponentPresetDao().find(manufacturerName, productNo);
+
+ ComponentPreset matchingPreset = null;
+
+ for (ComponentPreset preset : presets) {
+ if (digest != null && preset.getDigest().equals(digest)) {
+ // Found one with matching digest. Take it.
+ matchingPreset = preset;
+ break;
+ }
+ if (type != null && preset.getType().name().equals(type) && matchingPreset != null) {
+ // Found the first one with matching type.
+ matchingPreset = preset;
+ }
+ }
+
+ // Was any found?
+ if (matchingPreset == null) {
+ warnings.add(Warning.fromString("No matching ComponentPreset for component " + c.getName() + " found matching " + manufacturerName + " " + productNo));
+ return;
+ }
+
+ if (digest != null && !matchingPreset.getDigest().equals(digest)) {
+ warnings.add(Warning.fromString("ComponentPreset for component " + c.getName() + " has wrong digest"));
+ }
+
+ setMethod.invoke(c, matchingPreset);
}
-
- // Was any found?
- if ( matchingPreset == null ) {
- warnings.add(Warning.fromString("No matching ComponentPreset for component " + c.getName() + " found matching " + manufacturerName + " " + productNo));
- return;
- }
-
- if ( digest != null && !matchingPreset.getDigest().equals(digest) ) {
- warnings.add(Warning.fromString("ComponentPreset for component " + c.getName() + " has wrong digest"));
- }
-
- setMethod.invoke(c, matchingPreset);
-}
}
////MaterialSetter - sets a Material value
class MaterialSetter implements Setter {
-private final Reflection.Method setMethod;
-private final Material.Type type;
-
-public MaterialSetter(Reflection.Method set, Material.Type type) {
- this.setMethod = set;
- this.type = type;
-}
-
-@Override
-public void set(RocketComponent c, String name, HashMap<String, String> attributes,
- WarningSet warnings) {
-
- Material mat;
-
- // Check name != ""
- name = name.trim();
- if (name.equals("")) {
- warnings.add(Warning.fromString("Illegal material specification, ignoring."));
- return;
- }
-
- // Parse density
- double density;
- String str;
- str = attributes.remove("density");
- if (str == null) {
- warnings.add(Warning.fromString("Illegal material specification, ignoring."));
- return;
- }
- try {
- density = Double.parseDouble(str);
- } catch (NumberFormatException e) {
- warnings.add(Warning.fromString("Illegal material specification, ignoring."));
- return;
+ private final Reflection.Method setMethod;
+ private final Material.Type type;
+
+ public MaterialSetter(Reflection.Method set, Material.Type type) {
+ this.setMethod = set;
+ this.type = type;
}
-
- // Parse thickness
- // double thickness = 0;
- // str = attributes.remove("thickness");
- // try {
- // if (str != null)
- // thickness = Double.parseDouble(str);
- // } catch (NumberFormatException e){
- // warnings.add(Warning.fromString("Illegal material specification, ignoring."));
- // return;
- // }
-
- // Check type if specified
- str = attributes.remove("type");
- if (str != null && !type.name().toLowerCase(Locale.ENGLISH).equals(str)) {
- warnings.add(Warning.fromString("Illegal material type specified, ignoring."));
- return;
+
+ @Override
+ public void set(RocketComponent c, String name, HashMap<String, String> attributes,
+ WarningSet warnings) {
+
+ Material mat;
+
+ // Check name != ""
+ name = name.trim();
+ if (name.equals("")) {
+ warnings.add(Warning.fromString("Illegal material specification, ignoring."));
+ return;
+ }
+
+ // Parse density
+ double density;
+ String str;
+ str = attributes.remove("density");
+ if (str == null) {
+ warnings.add(Warning.fromString("Illegal material specification, ignoring."));
+ return;
+ }
+ try {
+ density = Double.parseDouble(str);
+ } catch (NumberFormatException e) {
+ warnings.add(Warning.fromString("Illegal material specification, ignoring."));
+ return;
+ }
+
+ // Parse thickness
+ // double thickness = 0;
+ // str = attributes.remove("thickness");
+ // try {
+ // if (str != null)
+ // thickness = Double.parseDouble(str);
+ // } catch (NumberFormatException e){
+ // warnings.add(Warning.fromString("Illegal material specification, ignoring."));
+ // return;
+ // }
+
+ // Check type if specified
+ str = attributes.remove("type");
+ if (str != null && !type.name().toLowerCase(Locale.ENGLISH).equals(str)) {
+ warnings.add(Warning.fromString("Illegal material type specified, ignoring."));
+ return;
+ }
+
+ mat = Databases.findMaterial(type, name, density);
+
+ setMethod.invoke(c, mat);
}
-
- String key = attributes.remove("key");
-
- mat = Databases.findMaterial(type, key, name, density);
-
- setMethod.invoke(c, mat);
-}
}
class PositionSetter implements Setter {
-
+
@Override
public void set(RocketComponent c, String value, HashMap<String, String> attributes,
WarningSet warnings) {
-
+
RocketComponent.Position type = (Position) DocumentConfig.findEnum(attributes.get("type"),
RocketComponent.Position.class);
if (type == null) {
warnings.add(Warning.FILE_INVALID_PARAMETER);
return;
}
-
+
double pos;
try {
pos = Double.parseDouble(value);
warnings.add(Warning.FILE_INVALID_PARAMETER);
return;
}
-
+
if (c instanceof FinSet) {
((FinSet) c).setRelativePosition(type);
c.setPositionValue(pos);
} else {
warnings.add(Warning.FILE_INVALID_PARAMETER);
}
-
+
}
}
class FinTabPositionSetter extends DoubleSetter {
-
+
public FinTabPositionSetter() {
super(Reflection.findMethod(FinSet.class, "setTabShift", double.class));
}
-
+
@Override
public void set(RocketComponent c, String s, HashMap<String, String> attributes,
WarningSet warnings) {
-
+
if (!(c instanceof FinSet)) {
throw new IllegalStateException("FinTabPositionSetter called for component " + c);
}
-
+
String relative = attributes.get("relativeto");
FinSet.TabRelativePosition position =
(TabRelativePosition) DocumentConfig.findEnum(relative,
FinSet.TabRelativePosition.class);
-
+
if (position != null) {
-
+
((FinSet) c).setTabRelativePosition(position);
-
+
} else {
if (relative == null) {
warnings.add("Required attribute 'relativeto' not found for fin tab position.");
warnings.add("Illegal attribute value '" + relative + "' encountered.");
}
}
-
+
super.set(c, s, attributes, warnings);
}
-
-
+
+
}
class ClusterConfigurationSetter implements Setter {
-
+
@Override
public void set(RocketComponent component, String value, HashMap<String, String> attributes,
WarningSet warnings) {
-
+
if (!(component instanceof Clusterable)) {
warnings.add("Illegal component defined as cluster.");
return;
}
-
+
ClusterConfiguration config = null;
for (ClusterConfiguration c : ClusterConfiguration.CONFIGURATIONS) {
if (c.getXMLName().equals(value)) {
break;
}
}
-
+
if (config == null) {
warnings.add("Illegal cluster configuration specified.");
return;
}
-
+
((Clusterable) component).setClusterConfiguration(config);
}
}
import java.util.Locale;
import net.sf.openrocket.file.RocketSaver;
+import net.sf.openrocket.l10n.Translator;
import net.sf.openrocket.material.Material;
import net.sf.openrocket.motor.Motor;
import net.sf.openrocket.motor.ThrustCurveMotor;
import net.sf.openrocket.rocketcomponent.MotorMount;
import net.sf.openrocket.rocketcomponent.Rocket;
import net.sf.openrocket.rocketcomponent.RocketComponent;
+import net.sf.openrocket.startup.Application;
import net.sf.openrocket.util.BugException;
import net.sf.openrocket.util.Color;
import net.sf.openrocket.util.LineStyle;
public class RocketComponentSaver {
-
+ private static final Translator trans = Application.getTranslator();
+
protected RocketComponentSaver() {
// Prevent instantiation from outside the package
}
-
+
protected void addParams(net.sf.openrocket.rocketcomponent.RocketComponent c, List<String> elements) {
elements.add("<name>" + RocketSaver.escapeXML(c.getName()) + "</name>");
-
+
ComponentPreset preset = c.getPresetComponent();
- if ( preset != null ) {
+ if (preset != null) {
elements.add("<preset type=\"" + preset.getType() +
"\" manufacturer=\"" + preset.getManufacturer().getSimpleName() +
- "\" partno=\"" + preset.getPartNo() + "\" digest=\"" + preset.getDigest() +"\"/>");
+ "\" partno=\"" + preset.getPartNo() + "\" digest=\"" + preset.getDigest() + "\"/>");
}
-
-
+
+
// Save color and line style if significant
if (!(c instanceof Rocket || c instanceof ComponentAssembly)) {
Color color = c.getColor();
elements.add("<color red=\"" + color.getRed() + "\" green=\"" + color.getGreen()
+ "\" blue=\"" + color.getBlue() + "\"/>");
}
-
+
LineStyle style = c.getLineStyle();
if (style != null) {
// Type names currently equivalent to the enum names except for case.
elements.add("<linestyle>" + style.name().toLowerCase(Locale.ENGLISH) + "</linestyle>");
}
}
-
-
+
+
// Save position unless "AFTER"
if (c.getRelativePosition() != RocketComponent.Position.AFTER) {
// The type names are currently equivalent to the enum names except for case.
String type = c.getRelativePosition().name().toLowerCase(Locale.ENGLISH);
elements.add("<position type=\"" + type + "\">" + c.getPositionValue() + "</position>");
}
-
-
+
+
// Overrides
boolean overridden = false;
if (c.isMassOverridden()) {
elements.add("<overridesubcomponents>" + c.getOverrideSubcomponents()
+ "</overridesubcomponents>");
}
-
-
+
+
// Comment
if (c.getComment().length() > 0) {
elements.add("<comment>" + RocketSaver.escapeXML(c.getComment()) + "</comment>");
}
-
+
}
-
-
-
-
+
+
+
+
protected final String materialParam(Material mat) {
return materialParam("material", mat);
}
-
-
+
+
protected final String materialParam(String tag, Material mat) {
String str = "<" + tag;
-
+
switch (mat.getType()) {
case LINE:
str += " type=\"line\"";
default:
throw new BugException("Unknown material type: " + mat.getType());
}
-
- return str + " density=\"" + mat.getDensity() + "\" key=\"" + RocketSaver.escapeXML(mat.getKey()) + "\">" + RocketSaver.escapeXML(mat.getName()) + "</" + tag + ">";
+
+ String baseName = trans.getBaseText("material", mat.getName());
+
+ return str + " density=\"" + mat.getDensity() + "\">" + RocketSaver.escapeXML(baseName) + "</" + tag + ">";
}
-
-
+
+
protected final List<String> motorMountParams(MotorMount mount) {
if (!mount.isMotorMount())
return Collections.emptyList();
-
+
String[] motorConfigIDs = ((RocketComponent) mount).getRocket().getMotorConfigurationIDs();
List<String> elements = new ArrayList<String>();
-
+
elements.add("<motormount>");
-
+
for (String id : motorConfigIDs) {
Motor motor = mount.getMotor(id);
-
+
// Nothing is stored if no motor loaded
if (motor == null)
continue;
-
+
elements.add(" <motor configid=\"" + id + "\">");
if (motor.getMotorType() != Motor.Type.UNKNOWN) {
elements.add(" <type>" + motor.getMotorType().name().toLowerCase(Locale.ENGLISH) + "</type>");
elements.add(" <designation>" + RocketSaver.escapeXML(motor.getDesignation()) + "</designation>");
elements.add(" <diameter>" + motor.getDiameter() + "</diameter>");
elements.add(" <length>" + motor.getLength() + "</length>");
-
+
// Motor delay
if (mount.getMotorDelay(id) == Motor.PLUGGED) {
elements.add(" <delay>none</delay>");
} else {
elements.add(" <delay>" + mount.getMotorDelay(id) + "</delay>");
}
-
+
elements.add(" </motor>");
}
-
+
elements.add(" <ignitionevent>"
+ mount.getIgnitionEvent().name().toLowerCase(Locale.ENGLISH).replace("_", "")
+ "</ignitionevent>");
-
+
elements.add(" <ignitiondelay>" + mount.getIgnitionDelay() + "</ignitiondelay>");
elements.add(" <overhang>" + mount.getMotorOverhang() + "</overhang>");
-
+
elements.add("</motormount>");
-
+
return elements;
}
-
+
}
*/
package net.sf.openrocket.file.rocksim.importt;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.HashMap;
+
import net.sf.openrocket.aerodynamics.WarningSet;
+import net.sf.openrocket.database.Databases;
import net.sf.openrocket.file.rocksim.RocksimCommonConstants;
import net.sf.openrocket.file.rocksim.RocksimDensityType;
import net.sf.openrocket.file.simplesax.AbstractElementHandler;
import net.sf.openrocket.material.Material;
import net.sf.openrocket.rocketcomponent.RocketComponent;
-import org.xml.sax.SAXException;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.util.HashMap;
+import org.xml.sax.SAXException;
/**
* An abstract base class that handles common parsing. All Rocksim component handlers are subclassed from here.
* @param <C> the specific RocketComponent subtype for which the concrete handler can create
*/
public abstract class BaseHandler<C extends RocketComponent> extends AbstractElementHandler {
-
- /**
- * Prepend rocksim materials.
- */
- public static final String ROCKSIM_MATERIAL_PREFIX = "RS: ";
- /**
- * The overridden mass.
- */
- private Double mass = 0d;
- /**
- * The overridden Cg.
- */
- private Double cg = 0d;
- /**
- * The density of the material in the component.
- */
- private Double density = 0d;
- /**
- * The internal Rocksim density type.
- */
- private RocksimDensityType densityType = RocksimDensityType.ROCKSIM_BULK;
-
- /**
- * The material name.
- */
- private String materialName = "";
-
- /**
- * The SAX method called when the closing element tag is reached.
- *
- * @param element the element name.
- * @param attributes attributes of the element.
- * @param content the textual content of the element.
- * @param warnings the warning set to store warnings in.
- *
- * @throws SAXException
- */
-
- @Override
- public void closeElement(String element, HashMap<String, String> attributes, String content, WarningSet warnings)
- throws SAXException {
- final C component = getComponent();
- try {
- if (RocksimCommonConstants.NAME.equals(element)) {
- component.setName(content);
- }
- if (RocksimCommonConstants.KNOWN_MASS.equals(element)) {
- mass = Math.max(0d, Double.parseDouble(content) / RocksimCommonConstants.ROCKSIM_TO_OPENROCKET_MASS);
- }
- if (RocksimCommonConstants.DENSITY.equals(element)) {
- density = Math.max(0d, Double.parseDouble(content));
- }
- if (RocksimCommonConstants.KNOWN_CG.equals(element)) {
- cg = Math.max(0d, Double.parseDouble(content) / RocksimCommonConstants.ROCKSIM_TO_OPENROCKET_LENGTH);
- }
- if (RocksimCommonConstants.USE_KNOWN_CG.equals(element)) { //Rocksim sets UseKnownCG to true to control the override of both cg and mass
- boolean override = "1".equals(content);
- setOverride(component, override, mass, cg);
- }
- if (RocksimCommonConstants.DENSITY_TYPE.equals(element)) {
- densityType = RocksimDensityType.fromCode(Integer.parseInt(content));
- }
- }
- catch (NumberFormatException nfe) {
- warnings.add("Could not convert " + element + " value of " + content + ". It is expected to be a number.");
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void endHandler(String element, HashMap<String, String> attributes, String content, WarningSet warnings)
- throws SAXException {
- /* Because of the order of XML elements in Rocksim, not all information is known at the time it really needs
- to be acted upon. So we keep temporary instance variables to be used here at the end of the parsing.
- */
- density = computeDensity(densityType, density);
- RocketComponent component = getComponent();
- updateComponentMaterial(component, materialName, getMaterialType(), density);
- }
-
- /**
- * Compute the density. Rocksim does strange things with densities. For some streamer material it's in cubic,
- * rather than square, units. In those cases it needs to be converted to an appropriate SURFACE material density.
- * Some G10 fiberglass materials are in cubic units, other G10 fiberglass is in square units. And due to a Rocksim
- * bug, some densities are 0 when they clearly should not be.
- * <p/>
- * This may be overridden for specific component density computations.
- *
- * @param type the rocksim density
- * @param rawDensity the density as specified in the Rocksim design file
- *
- * @return a value in OpenRocket SURFACE density units
- */
- protected double computeDensity(RocksimDensityType type, double rawDensity) {
- return rawDensity / type.asOpenRocket();
- }
-
- /**
- * If the Rocksim component does not override the mass, then create a Material based upon the density defined for
- * that component. This *should* result in a consistent representation of Cg between Rocksim and OpenRocket.
- *
- * @param component the component
- * @param type the type of the material
- * @param density the density in g/cm^3
- * @param definedMaterial the material that is currently defined on the component; used only to get the name as it
- * appears in Rocksim
- */
- public static void updateComponentMaterial(RocketComponent component, String definedMaterial, Material.Type type,
- double density) {
- if (definedMaterial != null) {
- Material custom = createCustomMaterial(type, definedMaterial, density);
- setMaterial(component, custom);
- }
- }
-
- /**
- * Override the mass and Cg of the component.
- *
- * @param component the component
- * @param override true if any override should happen
- * @param mass the override mass
- * @param cg the override cg
- */
- public static void setOverride(RocketComponent component, boolean override, double mass, double cg) {
- if (override) {
- component.setCGOverridden(override);
- component.setMassOverridden(override);
- component.setOverrideSubcomponents(false); //Rocksim does not support this type of override
- component.setOverrideMass(mass);
- component.setOverrideCGX(cg);
- }
- }
-
- /**
- * Get the component this handler is working upon.
- *
- * @return a component
- */
- protected abstract C getComponent();
-
- /**
- * Get the required type of material for this component.
- *
- * @return the required material type
- */
- protected abstract Material.Type getMaterialType();
-
- /**
- * Some CG positions in Rocksim do not correspond to the CG position reference in OpenRocket.
- *
- * @param theCG the CG value to really use when overriding CG on the OpenRocket component
- */
- protected void setCG(double theCG) {
- cg = theCG;
- }
-
- /**
- * Set the material name as specified in the Rocksim design file.
- *
- * @param content the material name
- */
- protected void setMaterialName(String content) {
- materialName = content;
- }
-
- /**
- * Get the Rocksim enum of the component's density type.
- *
- * @return a Rocksim density type
- */
- protected RocksimDensityType getDensityType() {
- return densityType;
- }
-
- /**
- * Add child to parent only if the child is compatible. Otherwise add to warning set.
- *
- * @param parent the parent component
- * @param child the child component
- * @param warnings the warning set
- *
- * @return true if the child is compatible with parent
- */
- protected static boolean isCompatible(RocketComponent parent, Class<? extends RocketComponent> child, WarningSet warnings) {
- return isCompatible(parent, child, warnings, false);
- }
-
- /**
- * Add child to parent only if the child is compatible. Otherwise add to warning set.
- *
- * @param parent the parent component
- * @param child the child component
- * @param warnings the warning set
- * @param suppressWarnings suppress warnings, just return the boolean
- *
- * @return true if the child is compatible with parent
- */
- protected static boolean isCompatible(RocketComponent parent, Class<? extends RocketComponent> child,
- WarningSet warnings,
- boolean suppressWarnings) {
- if (!parent.isCompatible(child)) {
- if (!suppressWarnings) {
- warnings.add(child.getName() + " can not be attached to "
- + parent.getComponentName() + ", ignoring component.");
- }
- return false;
- }
- else {
- return true;
- }
- }
-
- /**
- * Create a custom material based on the density. The name of the material is prepended with 'RS: ' to indicate it
- * came from a RockSim material.
- *
- * @param type the type of the material
- * @param name the name of the component
- * @param density the density
- *
- * @return a Material instance
- */
- public static Material createCustomMaterial(Material.Type type, String name, double density) {
- return Material.newUserMaterial(type, ROCKSIM_MATERIAL_PREFIX + name, density);
- }
-
- /**
- * Set the material onto an instance of RocketComponent. This is done because only some subtypes of RocketComponent
- * have the setMaterial method. Unfortunately the supertype cannot be used.
- *
- * @param component the component who's material is to be set
- * @param material the material to be set on the component (defined by getComponent())
- */
- private static void setMaterial(RocketComponent component, Material material) {
- try {
- final Method method = getMethod(component, "setMaterial", new Class[]{Material.class});
- if (method != null) {
- method.invoke(component, material);
- }
- }
- catch (IllegalAccessException ignored) {
- }
- catch (InvocationTargetException ignored) {
- }
- }
-
- /**
- * Find a method by name and argument list.
- *
- * @param component the component who's material is to be set
- * @param name the method name
- * @param args the class types of the parameters
- *
- * @return the Method instance, or null
- */
- private static Method getMethod(RocketComponent component, String name, Class[] args) {
- Method method = null;
- try {
- method = component.getClass().getMethod(name, args);
- }
- catch (NoSuchMethodException ignored) {
- }
- return method;
- }
-
+
+ /**
+ * Prepend rocksim materials.
+ */
+ public static final String ROCKSIM_MATERIAL_PREFIX = "RS: ";
+ /**
+ * The overridden mass.
+ */
+ private Double mass = 0d;
+ /**
+ * The overridden Cg.
+ */
+ private Double cg = 0d;
+ /**
+ * The density of the material in the component.
+ */
+ private Double density = 0d;
+ /**
+ * The internal Rocksim density type.
+ */
+ private RocksimDensityType densityType = RocksimDensityType.ROCKSIM_BULK;
+
+ /**
+ * The material name.
+ */
+ private String materialName = "";
+
+ /**
+ * The SAX method called when the closing element tag is reached.
+ *
+ * @param element the element name.
+ * @param attributes attributes of the element.
+ * @param content the textual content of the element.
+ * @param warnings the warning set to store warnings in.
+ *
+ * @throws SAXException
+ */
+
+ @Override
+ public void closeElement(String element, HashMap<String, String> attributes, String content, WarningSet warnings)
+ throws SAXException {
+ final C component = getComponent();
+ try {
+ if (RocksimCommonConstants.NAME.equals(element)) {
+ component.setName(content);
+ }
+ if (RocksimCommonConstants.KNOWN_MASS.equals(element)) {
+ mass = Math.max(0d, Double.parseDouble(content) / RocksimCommonConstants.ROCKSIM_TO_OPENROCKET_MASS);
+ }
+ if (RocksimCommonConstants.DENSITY.equals(element)) {
+ density = Math.max(0d, Double.parseDouble(content));
+ }
+ if (RocksimCommonConstants.KNOWN_CG.equals(element)) {
+ cg = Math.max(0d, Double.parseDouble(content) / RocksimCommonConstants.ROCKSIM_TO_OPENROCKET_LENGTH);
+ }
+ if (RocksimCommonConstants.USE_KNOWN_CG.equals(element)) { //Rocksim sets UseKnownCG to true to control the override of both cg and mass
+ boolean override = "1".equals(content);
+ setOverride(component, override, mass, cg);
+ }
+ if (RocksimCommonConstants.DENSITY_TYPE.equals(element)) {
+ densityType = RocksimDensityType.fromCode(Integer.parseInt(content));
+ }
+ } catch (NumberFormatException nfe) {
+ warnings.add("Could not convert " + element + " value of " + content + ". It is expected to be a number.");
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void endHandler(String element, HashMap<String, String> attributes, String content, WarningSet warnings)
+ throws SAXException {
+ /* Because of the order of XML elements in Rocksim, not all information is known at the time it really needs
+ to be acted upon. So we keep temporary instance variables to be used here at the end of the parsing.
+ */
+ density = computeDensity(densityType, density);
+ RocketComponent component = getComponent();
+ updateComponentMaterial(component, materialName, getMaterialType(), density);
+ }
+
+ /**
+ * Compute the density. Rocksim does strange things with densities. For some streamer material it's in cubic,
+ * rather than square, units. In those cases it needs to be converted to an appropriate SURFACE material density.
+ * Some G10 fiberglass materials are in cubic units, other G10 fiberglass is in square units. And due to a Rocksim
+ * bug, some densities are 0 when they clearly should not be.
+ * <p/>
+ * This may be overridden for specific component density computations.
+ *
+ * @param type the rocksim density
+ * @param rawDensity the density as specified in the Rocksim design file
+ *
+ * @return a value in OpenRocket SURFACE density units
+ */
+ protected double computeDensity(RocksimDensityType type, double rawDensity) {
+ return rawDensity / type.asOpenRocket();
+ }
+
+ /**
+ * If the Rocksim component does not override the mass, then create a Material based upon the density defined for
+ * that component. This *should* result in a consistent representation of Cg between Rocksim and OpenRocket.
+ *
+ * @param component the component
+ * @param type the type of the material
+ * @param density the density in g/cm^3
+ * @param definedMaterial the material that is currently defined on the component; used only to get the name as it
+ * appears in Rocksim
+ */
+ public static void updateComponentMaterial(RocketComponent component, String definedMaterial, Material.Type type,
+ double density) {
+ if (definedMaterial != null) {
+ Material custom = createCustomMaterial(type, definedMaterial, density);
+ setMaterial(component, custom);
+ }
+ }
+
+ /**
+ * Override the mass and Cg of the component.
+ *
+ * @param component the component
+ * @param override true if any override should happen
+ * @param mass the override mass
+ * @param cg the override cg
+ */
+ public static void setOverride(RocketComponent component, boolean override, double mass, double cg) {
+ if (override) {
+ component.setCGOverridden(override);
+ component.setMassOverridden(override);
+ component.setOverrideSubcomponents(false); //Rocksim does not support this type of override
+ component.setOverrideMass(mass);
+ component.setOverrideCGX(cg);
+ }
+ }
+
+ /**
+ * Get the component this handler is working upon.
+ *
+ * @return a component
+ */
+ protected abstract C getComponent();
+
+ /**
+ * Get the required type of material for this component.
+ *
+ * @return the required material type
+ */
+ protected abstract Material.Type getMaterialType();
+
+ /**
+ * Some CG positions in Rocksim do not correspond to the CG position reference in OpenRocket.
+ *
+ * @param theCG the CG value to really use when overriding CG on the OpenRocket component
+ */
+ protected void setCG(double theCG) {
+ cg = theCG;
+ }
+
+ /**
+ * Set the material name as specified in the Rocksim design file.
+ *
+ * @param content the material name
+ */
+ protected void setMaterialName(String content) {
+ materialName = content;
+ }
+
+ /**
+ * Get the Rocksim enum of the component's density type.
+ *
+ * @return a Rocksim density type
+ */
+ protected RocksimDensityType getDensityType() {
+ return densityType;
+ }
+
+ /**
+ * Add child to parent only if the child is compatible. Otherwise add to warning set.
+ *
+ * @param parent the parent component
+ * @param child the child component
+ * @param warnings the warning set
+ *
+ * @return true if the child is compatible with parent
+ */
+ protected static boolean isCompatible(RocketComponent parent, Class<? extends RocketComponent> child, WarningSet warnings) {
+ return isCompatible(parent, child, warnings, false);
+ }
+
+ /**
+ * Add child to parent only if the child is compatible. Otherwise add to warning set.
+ *
+ * @param parent the parent component
+ * @param child the child component
+ * @param warnings the warning set
+ * @param suppressWarnings suppress warnings, just return the boolean
+ *
+ * @return true if the child is compatible with parent
+ */
+ protected static boolean isCompatible(RocketComponent parent, Class<? extends RocketComponent> child,
+ WarningSet warnings,
+ boolean suppressWarnings) {
+ if (!parent.isCompatible(child)) {
+ if (!suppressWarnings) {
+ warnings.add(child.getName() + " can not be attached to "
+ + parent.getComponentName() + ", ignoring component.");
+ }
+ return false;
+ }
+ else {
+ return true;
+ }
+ }
+
+ /**
+ * Create a custom material based on the density.
+ *
+ * @param type the type of the material
+ * @param name the name of the component
+ * @param density the density
+ *
+ * @return a Material instance
+ */
+ public static Material createCustomMaterial(Material.Type type, String name, double density) {
+ return Databases.findMaterial(type, name, density);
+ }
+
+ /**
+ * Set the material onto an instance of RocketComponent. This is done because only some subtypes of RocketComponent
+ * have the setMaterial method. Unfortunately the supertype cannot be used.
+ *
+ * @param component the component who's material is to be set
+ * @param material the material to be set on the component (defined by getComponent())
+ */
+ private static void setMaterial(RocketComponent component, Material material) {
+ try {
+ final Method method = getMethod(component, "setMaterial", new Class[] { Material.class });
+ if (method != null) {
+ method.invoke(component, material);
+ }
+ } catch (IllegalAccessException ignored) {
+ } catch (InvocationTargetException ignored) {
+ }
+ }
+
+ /**
+ * Find a method by name and argument list.
+ *
+ * @param component the component who's material is to be set
+ * @param name the method name
+ * @param args the class types of the parameters
+ *
+ * @return the Method instance, or null
+ */
+ private static Method getMethod(RocketComponent component, String name, Class[] args) {
+ Method method = null;
+ try {
+ method = component.getClass().getMethod(name, args);
+ } catch (NoSuchMethodException ignored) {
+ }
+ return method;
+ }
+
}
import javax.swing.JTextField;
import net.miginfocom.swing.MigLayout;
+import net.sf.openrocket.database.Databases;
import net.sf.openrocket.gui.adaptors.DoubleModel;
import net.sf.openrocket.gui.components.StyledLabel;
import net.sf.openrocket.gui.components.UnitSelector;
import net.sf.openrocket.startup.Application;
public class CustomMaterialDialog extends JDialog {
-
+ private static final Translator trans = Application.getTranslator();
+
private final Material originalMaterial;
-
+
private boolean okClicked = false;
private JComboBox typeBox;
private JTextField nameField;
private JSpinner densitySpinner;
private UnitSelector densityUnit;
private JCheckBox addBox;
- private static final Translator trans = Application.getTranslator();
-
+
public CustomMaterialDialog(Window parent, Material material, boolean saveOption,
String title) {
this(parent, material, saveOption, title, null);
}
-
-
+
+
public CustomMaterialDialog(Window parent, Material material, boolean saveOption,
String title, String note) {
//// Custom material
super(parent, trans.get("custmatdlg.title.Custommaterial"), Dialog.ModalityType.APPLICATION_MODAL);
-
+
this.originalMaterial = material;
-
+
JPanel panel = new JPanel(new MigLayout("fill, gap rel unrel"));
-
-
+
+
// Add title and note
if (title != null) {
- panel.add(new JLabel("<html><b>" + title + ":"),
- "gapleft para, span, wrap" + (note == null ? " para":""));
+ panel.add(new JLabel("<html><b>" + title + ":"),
+ "gapleft para, span, wrap" + (note == null ? " para" : ""));
}
if (note != null) {
panel.add(new StyledLabel(note, -1), "span, wrap para");
}
-
-
+
+
//// Material name
panel.add(new JLabel(trans.get("custmatdlg.lbl.Materialname")));
nameField = new JTextField(15);
nameField.setText(material.getName());
}
panel.add(nameField, "span, growx, wrap");
-
-
+
+
// Material type (if not known)
panel.add(new JLabel(trans.get("custmatdlg.lbl.Materialtype")));
if (material == null) {
} else {
panel.add(new JLabel(material.getType().toString()), "span, growx, wrap");
}
-
-
+
+
// Material density:
panel.add(new JLabel(trans.get("custmatdlg.lbl.Materialdensity")));
densitySpinner = new JSpinner();
panel.add(densitySpinner, "w 70lp");
- densityUnit = new UnitSelector((DoubleModel)null);
+ densityUnit = new UnitSelector((DoubleModel) null);
panel.add(densityUnit, "w 30lp");
panel.add(new JPanel(), "growx, wrap");
updateDensityModel();
-
-
+
+
// Save option
if (saveOption) {
//// Add material to database
addBox = new JCheckBox(trans.get("custmatdlg.checkbox.Addmaterial"));
- panel.add(addBox,"span, wrap");
+ panel.add(addBox, "span, wrap");
}
-
+
//// OK button
JButton okButton = new JButton(trans.get("dlg.but.ok"));
-
+
okButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
CustomMaterialDialog.this.setVisible(false);
}
});
- panel.add(okButton,"span, split, tag ok");
-
+ panel.add(okButton, "span, split, tag ok");
+
//// Cancel
JButton closeButton = new JButton(trans.get("dlg.but.cancel"));
closeButton.addActionListener(new ActionListener() {
CustomMaterialDialog.this.setVisible(false);
}
});
- panel.add(closeButton,"tag cancel");
-
+ panel.add(closeButton, "tag cancel");
+
this.setContentPane(panel);
this.pack();
this.setLocationByPlatform(true);
GUIUtil.setDisposableDialogOptions(this, okButton);
}
-
-
+
+
public boolean getOkClicked() {
return okClicked;
}
-
-
+
+
public boolean isAddSelected() {
return addBox.isSelected();
}
-
-
+
+
public Material getMaterial() {
Material.Type type;
String name;
- double density;
-
+ double materialDensity;
+
if (typeBox != null) {
type = (Material.Type) typeBox.getSelectedItem();
} else {
type = originalMaterial.getType();
}
-
+
name = nameField.getText().trim();
-
- density = this.density.getValue();
-
- // If the name has not changed from the original name and we started with a system material.
- if ( name.equals( originalMaterial.getName()) ) {
- return Material.newUserMaterialWithKey(type, originalMaterial.getKey(), originalMaterial.getName(), density);
- } else {
- return Material.newUserMaterial(type, name, density);
- }
+
+ materialDensity = this.density.getValue();
+
+ return Databases.findMaterial(type, name, materialDensity);
}
-
-
+
+
private void updateDensityModel() {
if (originalMaterial != null) {
if (density == null) {
private static final String SPLIT_CHARACTER = "|";
-
+
private static final List<Locale> SUPPORTED_LOCALES;
static {
List<Locale> list = new ArrayList<Locale>();
- for (String lang : new String[] { "en", "de", "es", "fr", "it", "ru","cs","pl" }) {
+ for (String lang : new String[] { "en", "de", "es", "fr", "it", "ru", "cs", "pl" }) {
list.add(new Locale(lang));
}
SUPPORTED_LOCALES = Collections.unmodifiableList(list);
}
-
+
/**
* Whether to use the debug-node instead of the normal node.
*/
*/
private static final String NODENAME = (DEBUG ? "OpenRocket-debug" : "OpenRocket");
- private final Preferences PREFNODE;
+ private final Preferences PREFNODE;
+
-
public SwingPreferences() {
Preferences root = Preferences.userRoot();
if (DEBUG && CLEARPREFS) {
PREFNODE = root.node(NODENAME);
}
-
-
+
+
//////////////////////
-
-
+
+
/**
* Store the current OpenRocket version into the preferences to allow for preferences migration.
*/
}
@Override
- public String getString( String directory, String key, String defaultValue ) {
+ public String getString(String directory, String key, String defaultValue) {
Preferences p = PREFNODE.node(directory);
- return p.get(key,defaultValue);
+ return p.get(key, defaultValue);
}
/**
}
@Override
- public void putString(String directory, String key, String value ) {
+ public void putString(String directory, String key, String value) {
Preferences p = PREFNODE.node(directory);
- if ( value == null ) {
+ if (value == null) {
p.remove(key);
} else {
- p.put(key,value);
+ p.put(key, value);
}
storeVersion();
}
}
@Override
- public int getInt( String key, int defaultValue ) {
+ public int getInt(String key, int defaultValue) {
return PREFNODE.getInt(key, defaultValue);
}
@Override
- public void putInt( String key , int value ) {
- PREFNODE.putInt(key, value );
+ public void putInt(String key, int value) {
+ PREFNODE.putInt(key, value);
storeVersion();
}
@Override
public double getDouble(String key, double defaultValue) {
- return PREFNODE.getDouble(key, defaultValue );
+ return PREFNODE.getDouble(key, defaultValue);
}
-
+
@Override
public void putDouble(String key, double value) {
- PREFNODE.putDouble(key,value);
+ PREFNODE.putDouble(key, value);
storeVersion();
}
-
-
-
+
+
+
/**
* Return a preferences object for the specified node name.
*
//////////////////
-
+
public static List<Locale> getSupportedLocales() {
return SUPPORTED_LOCALES;
}
}
-
-
+
+
public Dimension getWindowSize(Class<?> c) {
int x, y;
String pref = PREFNODE.node("windows").get("size." + c.getCanonicalName(), null);
* you can pass (java.awt.Color) null to the second argument to
* disambiguate
*/
- public Color getColor( String key, Color defaultValue ) {
+ public Color getColor(String key, Color defaultValue) {
net.sf.openrocket.util.Color c = super.getColor(key, (net.sf.openrocket.util.Color) null);
- if ( c == null ) {
+ if (c == null) {
return defaultValue;
}
return ColorConversion.toAwtColor(c);
/**
*
*/
- public void putColor( String key, Color value ) {
+ public void putColor(String key, Color value) {
net.sf.openrocket.util.Color c = ColorConversion.fromAwtColor(value);
- super.putColor(key, c);
+ super.putColor(key, c);
}
//// Printing
}
-
+
///////// Export variables
public boolean isExportSelected(FlightDataType type) {
}
-
+
///////// Default unit storage
public void loadDefaultUnits() {
}
-
+
//// Material storage
-
+
/**
* Add a user-defined material to the preferences. The preferences are
* first checked for an existing material matching the provided one using
public void addUserMaterial(Material m) {
Preferences prefs = PREFNODE.node("userMaterials");
-
+
// Check whether material already exists
if (getUserMaterials().contains(m)) {
return;
String value = prefs.get(key, null);
try {
- Material existing = Material.fromStorableString(value);
+ Material existing = Material.fromStorableString(value, true);
if (existing.equals(m)) {
prefs.remove(key);
}
String value = prefs.get(key, null);
try {
- Material m = Material.fromStorableString(value);
+ Material m = Material.fromStorableString(value, true);
materials.add(m);
} catch (IllegalArgumentException e) {
}
@Override
- public void setComponentFavorite( ComponentPreset preset, ComponentPreset.Type type, boolean favorite ) {
+ public void setComponentFavorite(ComponentPreset preset, ComponentPreset.Type type, boolean favorite) {
Preferences prefs = PREFNODE.node("favoritePresets").node(type.name());
- if ( favorite ) {
+ if (favorite) {
prefs.putBoolean(preset.preferenceKey(), true);
} else {
prefs.remove(preset.preferenceKey());
}
@Override
- public Set<String> getComponentFavorites( ComponentPreset.Type type) {
+ public Set<String> getComponentFavorites(ComponentPreset.Type type) {
Preferences prefs = PREFNODE.node("favoritePresets").node(type.name());
Set<String> collection = new HashSet<String>();
try {
- collection.addAll( Arrays.asList(prefs.keys()));
- } catch ( BackingStoreException bex ) {
+ collection.addAll(Arrays.asList(prefs.keys()));
+ } catch (BackingStoreException bex) {
}
return collection;
*/
public class ClassBasedTranslator implements Translator {
-
+
private final Translator translator;
private final String className;
}
-
+
@Override
public String get(String key) {
String classKey = className + "." + key;
}
-
+
+ @Override
+ public String get(String base, String text) {
+ return translator.get(base, text);
+ }
+
+ @Override
+ public String getBaseText(String base, String translation) {
+ return translator.getBaseText(base, translation);
+ }
+
+
+
+
private static String getStackClass(int levels) {
TraceException trace = new TraceException();
StackTraceElement stack[] = trace.getStackTrace();
}
-
-
+
+
// For unit testing purposes
String getClassName() {
return className;
}
-
}
}
-
+
@Override
public String get(String key) {
if (translator != null) {
return "[" + key + "]";
}
+
+
+ @Override
+ public String get(String base, String text) {
+ return "[" + base + ":" + text + "]";
+ }
+
+
+
+ @Override
+ public String getBaseText(String base, String translation) {
+ if (translation.startsWith("[" + base + ":") && translation.endsWith("]")) {
+ return translation.substring(base.length() + 2, translation.length() - 1);
+ }
+ return translation;
+ }
+
+
}
}
-
+
@Override
public String get(String key) {
try {
}
-
+ @Override
+ public String get(String base, String text) {
+ return translator.get(base, text);
+ }
+
+
+ @Override
+ public String getBaseText(String base, String translation) {
+ return translator.getBaseText(base, translation);
+ }
+
+
private static synchronized void handleError(String key, MissingResourceException e) {
if (!errorReported) {
errorReported = true;
}
}
+
+
}
package net.sf.openrocket.l10n;
+import java.text.Normalizer;
import java.util.Locale;
import java.util.regex.Pattern;
+import net.sf.openrocket.util.Chars;
+
/**
* Helper methods for localization needs.
*
return l;
}
+
+ public static String normalize(String text) {
+ text = Normalizer.normalize(text, Normalizer.Form.NFKD);
+ text = text.toLowerCase();
+ text = text.replaceAll("\\s+", " ");
+ text = text.trim();
+
+ StringBuilder sb = new StringBuilder(text.length());
+ for (char c : text.toCharArray()) {
+ if ((c >= 'a' && c <= 'z') || (c >= '0' && c <= '9')) {
+ sb.append(c);
+ } else if (c == ' ' || c == '/' || c == Chars.FRACTION) {
+ sb.append('_');
+ }
+ }
+ text = sb.toString();
+
+ text = text.replaceAll("^_+", "");
+ text = text.replaceAll("_+$", "");
+
+ return text;
+ }
+
}
package net.sf.openrocket.l10n;
import java.util.Locale;
+import java.util.MissingResourceException;
import java.util.ResourceBundle;
/**
public class ResourceBundleTranslator implements Translator {
private final ResourceBundle bundle;
+ private final ResourceBundle english;
/**
* Create a ResourceBundleTranslator using the default Locale.
*/
public ResourceBundleTranslator(String baseName, Locale locale) {
this.bundle = ResourceBundle.getBundle(baseName, locale);
+ this.english = ResourceBundle.getBundle(baseName, Locale.ROOT);
}
return bundle.getString(key);
}
+ @Override
+ public synchronized String get(String base, String text) {
+ String key = base + "." + L10N.normalize(text);
+ try {
+ return bundle.getString(key);
+ } catch (MissingResourceException e) {
+ return text;
+ }
+ }
+
+ @Override
+ public synchronized String getBaseText(String base, String translation) {
+ String prefix = base + ".";
+ for (String key : bundle.keySet()) {
+ if (key.startsWith(prefix)) {
+ String value = bundle.getString(key);
+ if (value.equals(translation)) {
+ return english.getString(key);
+ }
+ }
+ }
+ return translation;
+ }
}
*/
public String get(String key);
+
+ /**
+ * Retrieve a translated string based on a base key and base (English) version of the text.
+ * The base text is normalized before using as a key.
+ * <p>
+ * This is meant to be used in very specific cases where the English name is
+ * used as a key for translation and storage. If a translation is not found,
+ * the base text is used instead.
+ *
+ * @param base the base for the logical key
+ * @param text the base (English) text to translate
+ * @return the translated string, or "text" if not found
+ */
+ public String get(String base, String text);
+
+
+ /**
+ * Find the base (English) version of a translated text.
+ * <p>
+ * This is the opposite operation of {@link #get(String, String)}, and
+ * meant for use in very specific cases when storing the values of
+ * translated texts.
+ *
+ * @param base the base for the logical key
+ * @param translation the translated string
+ * @return the base text, or the translation if not found.
+ */
+ public String getBaseText(String base, String translation);
+
}
package net.sf.openrocket.material;
-import net.sf.openrocket.database.Databases;
import net.sf.openrocket.l10n.Translator;
import net.sf.openrocket.startup.Application;
import net.sf.openrocket.unit.Unit;
public abstract class Material implements Comparable<Material> {
private static final Translator trans = Application.getTranslator();
-
+
public enum Type {
- LINE("Line", UnitGroup.UNITS_DENSITY_LINE),
- SURFACE("Surface", UnitGroup.UNITS_DENSITY_SURFACE),
- BULK("Bulk", UnitGroup.UNITS_DENSITY_BULK);
+ LINE("Databases.materials.types.Line", UnitGroup.UNITS_DENSITY_LINE),
+ SURFACE("Databases.materials.types.Surface", UnitGroup.UNITS_DENSITY_SURFACE),
+ BULK("Databases.materials.types.Bulk", UnitGroup.UNITS_DENSITY_BULK);
private final String name;
private final UnitGroup units;
- private Type(String name, UnitGroup units) {
- this.name = trans.get ("Databases.materials.types." + name);
+ private Type(String nameKey, UnitGroup units) {
+ this.name = trans.get(nameKey);
this.units = units;
}
///// Definitions of different material types /////
public static class Line extends Material {
- Line(String name, String key, double density, boolean userDefined) {
- super(name, key, density, userDefined);
+ Line(String name, double density, boolean userDefined) {
+ super(name, density, userDefined);
}
-
+
@Override
public Type getType() {
return Type.LINE;
public static class Surface extends Material {
- Surface(String name, String key, double density, boolean userDefined) {
- super(name, key, density, userDefined);
+ Surface(String name, double density, boolean userDefined) {
+ super(name, density, userDefined);
}
-
+
@Override
public Type getType() {
return Type.SURFACE;
}
public static class Bulk extends Material {
- Bulk(String name, String key, double density, boolean userDefined) {
- super(name, key, density, userDefined);
+ Bulk(String name, double density, boolean userDefined) {
+ super(name, density, userDefined);
}
-
+
@Override
public Type getType() {
return Type.BULK;
}
-
+
private final String name;
- private final String key;
private final double density;
private final boolean userDefined;
* @param density
* @param userDefined true if this is a user defined material, false if it is a system material.
*/
- private Material(String name, String key, double density, boolean userDefined) {
- if ( userDefined ) {
- this.key = "UserDefined."+name;
- this.name = name;
- } else {
- this.key = key;
- this.name = trans.get("Databases.materials." + key);
- }
+ private Material(String name, double density, boolean userDefined) {
+ this.name = name;
this.userDefined = userDefined;
this.density = density;
}
-
- public String getKey() {
- return key;
- }
public double getDensity() {
return density;
}
- public static Material newSystemMaterial(Type type, String key, double density ) {
- switch (type) {
- case LINE:
- return new Material.Line(null, key, density, false);
-
- case SURFACE:
- return new Material.Surface(null,key, density, false);
-
- case BULK:
- return new Material.Bulk(null, key, density, false);
-
- default:
- throw new IllegalArgumentException("Unknown material type: " + type);
- }
- }
-
/**
- * Return a new user defined material of the specified type.
- */
- public static Material newUserMaterial(Type type, String name, double density) {
- switch (type) {
- case LINE:
- return new Material.Line(name, null, density, true);
-
- case SURFACE:
- return new Material.Surface(name, null, density, true);
-
- case BULK:
- return new Material.Bulk(name, null, density, true);
-
- default:
- throw new IllegalArgumentException("Unknown material type: " + type);
- }
- }
-
- /**
- * Return a new user defined material of the specified type and localizable key.
+ * Return a new material. The name is used as-is, without any translation.
+ *
+ * @param type the material type
+ * @param name the material name
+ * @param density the material density
+ * @param userDefined whether the material is user-defined or not
+ * @return the new material
*/
- public static Material newUserMaterialWithKey(Type type, String key, String name, double density) {
+ public static Material newMaterial(Type type, String name, double density, boolean userDefined) {
switch (type) {
case LINE:
- return new Material.Line(name, key, density, true);
+ return new Material.Line(name, density, userDefined);
case SURFACE:
- return new Material.Surface(name, key, density, true);
+ return new Material.Surface(name, density, userDefined);
case BULK:
- return new Material.Bulk(name, key, density, true);
+ return new Material.Bulk(name, density, userDefined);
default:
throw new IllegalArgumentException("Unknown material type: " + type);
}
}
-
-
public String toStorableString() {
- return getType().name() + "|" + key + "|" + name.replace('|', ' ') + '|' + density;
+ return getType().name() + "|" + name.replace('|', ' ') + '|' + density;
}
* @return a new <code>Material</code> object.
* @throws IllegalArgumentException if <code>str</code> is invalid or null.
*/
- public static Material fromStorableString(String str) {
+ public static Material fromStorableString(String str, boolean userDefined) {
if (str == null)
throw new IllegalArgumentException("Material string is null");
- String[] split = str.split("\\|");
+ String[] split = str.split("\\|", 3);
if (split.length < 3)
throw new IllegalArgumentException("Illegal material string: " + str);
Type type = null;
- String name = null;
- String key= null;
- String densityString;
+ String name;
+ double density;
try {
type = Type.valueOf(split[0]);
throw new IllegalArgumentException("Illegal material string: " + str, e);
}
- if ( split.length == 3 ) {
- name = split[1];
- densityString =split[2];
- } else {
- key = split[1];
- name = split[2];
- densityString=split[3];
- }
-
+ name = split[1];
- double density;
-
try {
- density = Double.parseDouble(densityString);
+ density = Double.parseDouble(split[2]);
} catch (NumberFormatException e) {
throw new IllegalArgumentException("Illegal material string: " + str, e);
}
- return Databases.findMaterial(type, key, name, density);
+ switch (type) {
+ case BULK:
+ return new Material.Bulk(name, density, userDefined);
+
+ case SURFACE:
+ return new Material.Surface(name, density, userDefined);
+
+ case LINE:
+ return new Material.Line(name, density, userDefined);
+
+ default:
+ throw new IllegalArgumentException("Illegal material string: " + str);
+ }
}
}
package net.sf.openrocket.preset;
import static net.sf.openrocket.preset.ComponentPreset.*;
+import net.sf.openrocket.database.Databases;
import net.sf.openrocket.material.Material;
import net.sf.openrocket.preset.ComponentPreset.Type;
import net.sf.openrocket.rocketcomponent.NoseCone;
import net.sf.openrocket.rocketcomponent.Transition;
public abstract class ComponentPresetFactory {
-
- public static ComponentPreset create( TypedPropertyMap props ) throws InvalidComponentPresetException {
-
+
+ public static ComponentPreset create(TypedPropertyMap props) throws InvalidComponentPresetException {
+
InvalidComponentPresetException exceptions = new InvalidComponentPresetException("Invalid preset specification.");
ComponentPreset preset = new ComponentPreset();
// First do validation.
if (!props.containsKey(MANUFACTURER)) {
- exceptions.addInvalidParameter(MANUFACTURER, "No Manufacturer specified");
+ exceptions.addInvalidParameter(MANUFACTURER, "No Manufacturer specified");
}
if (!props.containsKey(PARTNO)) {
- exceptions.addInvalidParameter(PARTNO,"No PartNo specified");
+ exceptions.addInvalidParameter(PARTNO, "No PartNo specified");
}
- if ( !props.containsKey(TYPE)) {
- exceptions.addInvalidParameter(TYPE, "No Type specified" );
+ if (!props.containsKey(TYPE)) {
+ exceptions.addInvalidParameter(TYPE, "No Type specified");
// We can't do anything else without TYPE so throw immediately.
throw exceptions;
}
-
-
+
+
preset.putAll(props);
-
+
// Should check for various bits of each of the types.
Type t = props.get(TYPE);
- switch ( t ) {
+ switch (t) {
case BODY_TUBE: {
- makeBodyTube(exceptions,preset);
+ makeBodyTube(exceptions, preset);
break;
}
case NOSE_CONE: {
- makeNoseCone(exceptions,preset);
+ makeNoseCone(exceptions, preset);
break;
}
case TRANSITION: {
- makeTransition(exceptions,preset);
+ makeTransition(exceptions, preset);
break;
}
case BULK_HEAD: {
- makeBulkHead(exceptions,preset);
+ makeBulkHead(exceptions, preset);
break;
}
case TUBE_COUPLER: {
// For now TUBE_COUPLER is the same as BODY_TUBE
- makeBodyTube(exceptions,preset);
+ makeBodyTube(exceptions, preset);
break;
}
case CENTERING_RING: {
- makeCenteringRing(exceptions,preset);
+ makeCenteringRing(exceptions, preset);
break;
}
case ENGINE_BLOCK: {
- makeEngineBlock(exceptions,preset);
+ makeEngineBlock(exceptions, preset);
break;
}
case LAUNCH_LUG: {
// Same processing as BODY_TUBE
- makeBodyTube(exceptions,preset);
+ makeBodyTube(exceptions, preset);
break;
}
case STREAMER: {
- makeStreamer(exceptions,preset);
+ makeStreamer(exceptions, preset);
break;
}
case PARACHUTE: {
- makeParachute(exceptions,preset);
+ makeParachute(exceptions, preset);
break;
}
}
-
- if ( exceptions.hasProblems() ) {
+
+ if (exceptions.hasProblems()) {
throw exceptions;
}
preset.computeDigest();
-
+
return preset;
-
+
}
-
- private static void makeBodyTube( InvalidComponentPresetException exceptions, ComponentPreset preset ) throws InvalidComponentPresetException {
+
+ private static void makeBodyTube(InvalidComponentPresetException exceptions, ComponentPreset preset) throws InvalidComponentPresetException {
+
+ checkRequiredFields(exceptions, preset, LENGTH);
- checkRequiredFields( exceptions, preset, LENGTH );
-
checkDiametersAndThickness(exceptions, preset);
- double volume = computeVolumeOfTube( preset );
+ double volume = computeVolumeOfTube(preset);
// Need to translate Mass to Density.
- if ( preset.has(MASS) ) {
+ if (preset.has(MASS)) {
String materialName = "TubeCustom";
- if ( preset.has(MATERIAL) ) {
+ if (preset.has(MATERIAL)) {
materialName = preset.get(MATERIAL).getName();
}
- Material m = Material.newUserMaterial(Material.Type.BULK, materialName, preset.get(MASS)/volume);
+ Material m = Databases.findMaterial(Material.Type.BULK, materialName, preset.get(MASS) / volume);
preset.put(MATERIAL, m);
}
-
-
+
+
}
-
- private static void makeNoseCone( InvalidComponentPresetException exceptions, ComponentPreset preset ) {
-
- checkRequiredFields( exceptions, preset, LENGTH, SHAPE, AFT_OUTER_DIAMETER );
-
- if ( preset.has(MASS) ) {
+
+ private static void makeNoseCone(InvalidComponentPresetException exceptions, ComponentPreset preset) {
+
+ checkRequiredFields(exceptions, preset, LENGTH, SHAPE, AFT_OUTER_DIAMETER);
+
+ if (preset.has(MASS)) {
// compute a density for this component
double mass = preset.get(MASS);
NoseCone nc = new NoseCone();
nc.loadPreset(preset);
double density = mass / nc.getComponentVolume();
-
+
String materialName = "NoseConeCustom";
- if ( preset.has(MATERIAL) ) {
+ if (preset.has(MATERIAL)) {
materialName = preset.get(MATERIAL).getName();
}
-
- Material m = Material.newUserMaterial(Material.Type.BULK, materialName,density);
+
+ Material m = Databases.findMaterial(Material.Type.BULK, materialName, density);
preset.put(MATERIAL, m);
-
+
}
-
+
}
-
- private static void makeTransition( InvalidComponentPresetException exceptions, ComponentPreset preset ) {
+
+ private static void makeTransition(InvalidComponentPresetException exceptions, ComponentPreset preset) {
checkRequiredFields(exceptions, preset, LENGTH, AFT_OUTER_DIAMETER, FORE_OUTER_DIAMETER);
-
- if ( preset.has(MASS) ) {
+
+ if (preset.has(MASS)) {
// compute a density for this component
double mass = preset.get(MASS);
Transition tr = new Transition();
tr.loadPreset(preset);
double density = mass / tr.getComponentVolume();
-
+
String materialName = "TransitionCustom";
- if ( preset.has(MATERIAL) ) {
+ if (preset.has(MATERIAL)) {
materialName = preset.get(MATERIAL).getName();
}
-
- Material m = Material.newUserMaterial(Material.Type.BULK, materialName,density);
+
+ Material m = Databases.findMaterial(Material.Type.BULK, materialName, density);
preset.put(MATERIAL, m);
-
+
}
-
+
}
-
- private static void makeBulkHead( InvalidComponentPresetException exceptions, ComponentPreset preset ) {
- checkRequiredFields(exceptions, preset, LENGTH, OUTER_DIAMETER );
-
- if ( preset.has(MASS) ) {
+
+ private static void makeBulkHead(InvalidComponentPresetException exceptions, ComponentPreset preset) {
+ checkRequiredFields(exceptions, preset, LENGTH, OUTER_DIAMETER);
+
+ if (preset.has(MASS)) {
// compute a density for this component
double mass = preset.get(MASS);
-
+
double volume = computeVolumeOfTube(preset);
double density = mass / volume;
-
+
String materialName = "BulkHeadCustom";
- if ( preset.has(MATERIAL) ) {
+ if (preset.has(MATERIAL)) {
materialName = preset.get(MATERIAL).getName();
}
-
- Material m = Material.newUserMaterial(Material.Type.BULK, materialName,density);
+
+ Material m = Databases.findMaterial(Material.Type.BULK, materialName, density);
preset.put(MATERIAL, m);
-
+
}
-
+
}
-
- private static void makeCenteringRing( InvalidComponentPresetException exceptions, ComponentPreset preset ) throws InvalidComponentPresetException {
- checkRequiredFields( exceptions, preset, LENGTH );
-
- checkDiametersAndThickness( exceptions, preset );
-
- double volume = computeVolumeOfTube( preset );
-
+
+ private static void makeCenteringRing(InvalidComponentPresetException exceptions, ComponentPreset preset) throws InvalidComponentPresetException {
+ checkRequiredFields(exceptions, preset, LENGTH);
+
+ checkDiametersAndThickness(exceptions, preset);
+
+ double volume = computeVolumeOfTube(preset);
+
// Need to translate Mass to Density.
- if ( preset.has(MASS) ) {
+ if (preset.has(MASS)) {
String materialName = "CenteringRingCustom";
- if ( preset.has(MATERIAL) ) {
+ if (preset.has(MATERIAL)) {
materialName = preset.get(MATERIAL).getName();
}
- Material m = Material.newUserMaterial(Material.Type.BULK, materialName, preset.get(MASS)/volume);
+ Material m = Databases.findMaterial(Material.Type.BULK, materialName, preset.get(MASS) / volume);
preset.put(MATERIAL, m);
}
-
+
}
- private static void makeEngineBlock( InvalidComponentPresetException exceptions, ComponentPreset preset ) throws InvalidComponentPresetException {
- checkRequiredFields( exceptions, preset, LENGTH );
-
- checkDiametersAndThickness( exceptions, preset );
-
- double volume = computeVolumeOfTube( preset );
-
+ private static void makeEngineBlock(InvalidComponentPresetException exceptions, ComponentPreset preset) throws InvalidComponentPresetException {
+ checkRequiredFields(exceptions, preset, LENGTH);
+
+ checkDiametersAndThickness(exceptions, preset);
+
+ double volume = computeVolumeOfTube(preset);
+
// Need to translate Mass to Density.
- if ( preset.has(MASS) ) {
+ if (preset.has(MASS)) {
String materialName = "EngineBlockCustom";
- if ( preset.has(MATERIAL) ) {
+ if (preset.has(MATERIAL)) {
materialName = preset.get(MATERIAL).getName();
}
- Material m = Material.newUserMaterial(Material.Type.BULK, materialName, preset.get(MASS)/volume);
+ Material m = Databases.findMaterial(Material.Type.BULK, materialName, preset.get(MASS) / volume);
preset.put(MATERIAL, m);
}
-
+
}
- private static void makeStreamer( InvalidComponentPresetException exceptions, ComponentPreset preset ) {
- checkRequiredFields( exceptions, preset, LENGTH, WIDTH );
+ private static void makeStreamer(InvalidComponentPresetException exceptions, ComponentPreset preset) {
+ checkRequiredFields(exceptions, preset, LENGTH, WIDTH);
}
-
- private static void makeParachute( InvalidComponentPresetException exceptions, ComponentPreset preset ) {
- checkRequiredFields( exceptions, preset, DIAMETER, LINE_COUNT, LINE_LENGTH );
+
+ private static void makeParachute(InvalidComponentPresetException exceptions, ComponentPreset preset) {
+ checkRequiredFields(exceptions, preset, DIAMETER, LINE_COUNT, LINE_LENGTH);
}
-
- private static void checkRequiredFields( InvalidComponentPresetException exceptions, ComponentPreset preset, TypedKey<?> ... keys ) {
- for( TypedKey<?> key: keys ) {
- if (! preset.has(key) ) {
+
+ private static void checkRequiredFields(InvalidComponentPresetException exceptions, ComponentPreset preset, TypedKey<?>... keys) {
+ for (TypedKey<?> key : keys) {
+ if (!preset.has(key)) {
exceptions.addInvalidParameter(key, "No " + key.getName() + " specified");
}
}
}
-
- private static void checkDiametersAndThickness( InvalidComponentPresetException exceptions, ComponentPreset preset ) throws InvalidComponentPresetException {
+
+ private static void checkDiametersAndThickness(InvalidComponentPresetException exceptions, ComponentPreset preset) throws InvalidComponentPresetException {
// Need to verify contains 2 of OD, thickness, ID. Compute the third.
boolean hasOd = preset.has(OUTER_DIAMETER);
boolean hasId = preset.has(INNER_DIAMETER);
boolean hasThickness = preset.has(THICKNESS);
-
+
double outerRadius;
double innerRadius;
double thickness;
- if ( hasOd ) {
- outerRadius = preset.get(OUTER_DIAMETER)/2.0;
+ if (hasOd) {
+ outerRadius = preset.get(OUTER_DIAMETER) / 2.0;
thickness = 0;
- if ( hasId ) {
- innerRadius = preset.get(INNER_DIAMETER)/2.0;
+ if (hasId) {
+ innerRadius = preset.get(INNER_DIAMETER) / 2.0;
thickness = outerRadius - innerRadius;
- } else if ( hasThickness ) {
+ } else if (hasThickness) {
thickness = preset.get(THICKNESS);
innerRadius = outerRadius - thickness;
} else {
throw exceptions;
}
} else {
- if ( ! hasId || ! hasThickness ) {
+ if (!hasId || !hasThickness) {
exceptions.addMessage("Preset dimensions underspecified");
throw exceptions;
}
- innerRadius = preset.get(INNER_DIAMETER)/2.0;
+ innerRadius = preset.get(INNER_DIAMETER) / 2.0;
thickness = preset.get(THICKNESS);
outerRadius = innerRadius + thickness;
}
-
- preset.put(OUTER_DIAMETER, outerRadius *2.0);
- preset.put(INNER_DIAMETER, innerRadius *2.0);
- preset.put(THICKNESS, thickness );
-
+
+ preset.put(OUTER_DIAMETER, outerRadius * 2.0);
+ preset.put(INNER_DIAMETER, innerRadius * 2.0);
+ preset.put(THICKNESS, thickness);
+
}
private static double computeVolumeOfTube(ComponentPreset preset) {
- double or = preset.get(OUTER_DIAMETER)/2.0;
- double ir = preset.has(INNER_DIAMETER) ? preset.get(INNER_DIAMETER)/2.0 : 0.0;
+ double or = preset.get(OUTER_DIAMETER) / 2.0;
+ double ir = preset.has(INNER_DIAMETER) ? preset.get(INNER_DIAMETER) / 2.0 : 0.0;
double l = preset.get(LENGTH);
- return Math.PI * (or*or - ir*ir) * l;
+ return Math.PI * (or * or - ir * ir) * l;
}
-
+
}
package net.sf.openrocket.preset.loader;
+import net.sf.openrocket.database.Databases;
import net.sf.openrocket.material.Material;
import net.sf.openrocket.preset.TypedKey;
import net.sf.openrocket.preset.TypedPropertyMap;
public class LineMaterialColumnParser extends BaseColumnParser {
-
+
private final MaterialHolder materialMap;
-
+
private final TypedKey<Material> param;
public LineMaterialColumnParser(MaterialHolder materialMap, String columnName, TypedKey<Material> param) {
this.materialMap = materialMap;
}
-
+
@Override
protected void doParse(String columnData, String[] data, TypedPropertyMap props) {
-
- if ( columnData == null || "".equals(columnData.trim())) {
+
+ if (columnData == null || "".equals(columnData.trim())) {
return;
}
- Material.Line myMaterial = (Material.Line) Material.newUserMaterial(Material.Type.LINE, columnData, 0.0);
-
+ Material.Line myMaterial = (Material.Line) Databases.findMaterial(Material.Type.LINE, columnData, 0.0);
+
Material.Line m = materialMap.getLineMaterial(myMaterial);
- props.put(param, m!=null? m : myMaterial);
-
+ props.put(param, m != null ? m : myMaterial);
+
}
-
+
}
package net.sf.openrocket.preset.loader;
+import net.sf.openrocket.database.Databases;
import net.sf.openrocket.material.Material;
import net.sf.openrocket.preset.ComponentPreset;
import net.sf.openrocket.preset.TypedKey;
import net.sf.openrocket.preset.TypedPropertyMap;
public class MaterialColumnParser extends BaseColumnParser {
-
+
private final MaterialHolder materialMap;
-
+
private final TypedKey<Material> param;
public MaterialColumnParser(MaterialHolder materialMap, String columnName, TypedKey<Material> param) {
this(materialMap, "Material", ComponentPreset.MATERIAL);
}
-
+
@Override
protected void doParse(String columnData, String[] data, TypedPropertyMap props) {
-
- if ( columnData == null || "".equals(columnData.trim())) {
+
+ if (columnData == null || "".equals(columnData.trim())) {
return;
}
- Material.Bulk tmpMaterial = (Material.Bulk) Material.newUserMaterial( Material.Type.BULK,columnData, 0.0);
+ Material.Bulk tmpMaterial = (Material.Bulk) Databases.findMaterial(Material.Type.BULK, columnData, 0.0);
Material.Bulk m = materialMap.getBulkMaterial(tmpMaterial);
- props.put(param, m!= null ? m : tmpMaterial);
+ props.put(param, m != null ? m : tmpMaterial);
}
-
+
}
import java.util.Map;
import net.sf.openrocket.database.Database;
+import net.sf.openrocket.database.Databases;
import net.sf.openrocket.material.Material;
import net.sf.openrocket.unit.UnitGroup;
public class MaterialHolder {
-
- private final Map<String,Material.Bulk> bulkMaterials = new HashMap<String,Material.Bulk>();
-
- private final Map<String,Material.Surface> surfaceMaterials = new HashMap<String,Material.Surface>();
-
- private final Map<String, Material.Line> lineMaterials = new HashMap<String,Material.Line>();
-
- public MaterialHolder() {}
- public MaterialHolder( List<Material> materials ) {
+ private final Map<String, Material.Bulk> bulkMaterials = new HashMap<String, Material.Bulk>();
+
+ private final Map<String, Material.Surface> surfaceMaterials = new HashMap<String, Material.Surface>();
+
+ private final Map<String, Material.Line> lineMaterials = new HashMap<String, Material.Line>();
+
+ public MaterialHolder() {
+ }
+
+ public MaterialHolder(List<Material> materials) {
if (materials == null) {
return;
}
}
}
- public void put( Material material ) {
- switch ( material.getType() ) {
+ public void put(Material material) {
+ switch (material.getType()) {
case BULK:
bulkMaterials.put(material.getName(), (Material.Bulk) material);
break;
break;
}
}
-
- public Material getMaterial ( Material material ) {
- switch ( material.getType() ) {
+
+ public Material getMaterial(Material material) {
+ switch (material.getType()) {
case BULK:
- return getBulkMaterial( (Material.Bulk)material );
+ return getBulkMaterial((Material.Bulk) material);
case SURFACE:
- return getSurfaceMaterial( (Material.Surface) material, null );
+ return getSurfaceMaterial((Material.Surface) material, null);
case LINE:
- return getLineMaterial( (Material.Line) material );
+ return getLineMaterial((Material.Line) material);
default:
return null;
}
}
-
- public Material.Bulk getBulkMaterial( Material.Bulk material ) {
- Material.Bulk m = bulkMaterials.get( material.getName() );
+
+ public Material.Bulk getBulkMaterial(Material.Bulk material) {
+ Material.Bulk m = bulkMaterials.get(material.getName());
return m;
}
-
- public Material.Surface getSurfaceMaterial( Material.Surface material, Double thickness ) {
- Material.Surface m = surfaceMaterials.get(material.getName() );
- if ( m != null ) {
+
+ public Material.Surface getSurfaceMaterial(Material.Surface material, Double thickness) {
+ Material.Surface m = surfaceMaterials.get(material.getName());
+ if (m != null) {
return m;
}
// Try to see if we can convert a bulk material.
- if ( thickness == null ) {
+ if (thickness == null) {
// if we have no thickness, there is nothing we can do
return null;
}
String thicknessName = UnitGroup.UNITS_LENGTH.getUnit("mm").toString(thickness);
String convertedMaterialName = material.getName() + "(" + thicknessName + ")";
m = surfaceMaterials.get(convertedMaterialName);
- if ( m != null ) {
+ if (m != null) {
return m;
}
- Material.Bulk bulk = bulkMaterials.get(material.getName() );
-
- if ( bulk == null ) {
+ Material.Bulk bulk = bulkMaterials.get(material.getName());
+
+ if (bulk == null) {
return null;
}
-
+
// Ok, now we have a thickness and a bulk material of the correct name,
// we can make our own surface material.
-
- Material.Surface surface = (Material.Surface) Material.newUserMaterial(Material.Type.SURFACE, convertedMaterialName, bulk.getDensity() * thickness);
-
+
+ Material.Surface surface = (Material.Surface) Databases.findMaterial(Material.Type.SURFACE, convertedMaterialName, bulk.getDensity() * thickness);
+
this.put(surface);
-
+
return surface;
-
+
}
-
- public Material.Line getLineMaterial( Material.Line material ) {
- Material.Line m = lineMaterials.get( material.getName() );
+
+ public Material.Line getLineMaterial(Material.Line material) {
+ Material.Line m = lineMaterials.get(material.getName());
return m;
}
-
+
public int size() {
return bulkMaterials.size() + surfaceMaterials.size() + lineMaterials.size();
}
-
+
public Collection<Material> values() {
-
+
HashSet<Material> allMats = new HashSet<Material>();
- allMats.addAll( bulkMaterials.values() );
- allMats.addAll( surfaceMaterials.values() );
- allMats.addAll( lineMaterials.values() );
-
+ allMats.addAll(bulkMaterials.values());
+ allMats.addAll(surfaceMaterials.values());
+ allMats.addAll(lineMaterials.values());
+
return allMats;
-
+
}
-
+
public Database<Material> asDatabase(Material.Type theType) {
Database<Material> result = new Database<Material>();
switch (theType) {
package net.sf.openrocket.preset.loader;
+import java.io.File;
+
+import net.sf.openrocket.database.Databases;
import net.sf.openrocket.material.Material;
import net.sf.openrocket.preset.TypedKey;
import net.sf.openrocket.preset.TypedPropertyMap;
import net.sf.openrocket.util.BugException;
-import java.io.File;
-
public class MaterialLoader extends RocksimComponentFileLoader {
-
+
private MaterialHolder materialMap = new MaterialHolder();
-
+
private final static TypedKey<String> MATERIALNAME = new TypedKey<String>("MaterialName", String.class);
private final static TypedKey<String> UNITS = new TypedKey<String>("Units", String.class);
private final static TypedKey<Double> DENSITY = new TypedKey<Double>("Density", Double.class);
-
+
public MaterialLoader(File theBasePathToLoadFrom) {
super(theBasePathToLoadFrom);
- fileColumns.add( new StringColumnParser("Material Name", MATERIALNAME) );
- fileColumns.add( new StringColumnParser("Units", UNITS));
- fileColumns.add( new DoubleColumnParser("Density", DENSITY));
+ fileColumns.add(new StringColumnParser("Material Name", MATERIALNAME));
+ fileColumns.add(new StringColumnParser("Units", UNITS));
+ fileColumns.add(new DoubleColumnParser("Density", DENSITY));
}
-
+
@Override
protected RocksimComponentFileType getFileType() {
return RocksimComponentFileType.MATERIAL;
}
-
+
public MaterialHolder getMaterialMap() {
return materialMap;
}
-
+
@Override
protected void postProcess(TypedPropertyMap props) {
String name = props.get(MATERIALNAME);
String unit = props.get(UNITS);
double density = props.get(DENSITY);
-
+
String cleanedMaterialName = stripAll(name, '"').trim();
-
- if ( "g/cm".equals( unit ) ) {
- materialMap.put( Material.newUserMaterial(Material.Type.LINE,cleanedMaterialName, 0.1d * density));
- } else if ( "g/cm2".equals(unit) ) {
- materialMap.put( Material.newUserMaterial(Material.Type.SURFACE,cleanedMaterialName, 10.0d * density));
- } else if ( "g/cm3".equals(unit) ) {
- materialMap.put( Material.newUserMaterial(Material.Type.BULK,cleanedMaterialName, 1000.0d * density));
- } else if ( "kg/m3".equals(unit) ) {
- materialMap.put( Material.newUserMaterial(Material.Type.BULK,cleanedMaterialName, density));
- } else if ( "lb/ft3".equals(unit) ) {
- materialMap.put( Material.newUserMaterial(Material.Type.BULK,cleanedMaterialName, 16.0184634d * density));
- } else if ( "oz/in".equals(unit) ) {
- materialMap.put( Material.newUserMaterial(Material.Type.LINE,cleanedMaterialName, 1.11612296d * density));
- } else if ( "oz/in2".equals(unit ) ) {
- materialMap.put( Material.newUserMaterial(Material.Type.SURFACE,cleanedMaterialName, 43.94184876d * density));
+
+ if ("g/cm".equals(unit)) {
+ materialMap.put(Databases.findMaterial(Material.Type.LINE, cleanedMaterialName, 0.1d * density));
+ } else if ("g/cm2".equals(unit)) {
+ materialMap.put(Databases.findMaterial(Material.Type.SURFACE, cleanedMaterialName, 10.0d * density));
+ } else if ("g/cm3".equals(unit)) {
+ materialMap.put(Databases.findMaterial(Material.Type.BULK, cleanedMaterialName, 1000.0d * density));
+ } else if ("kg/m3".equals(unit)) {
+ materialMap.put(Databases.findMaterial(Material.Type.BULK, cleanedMaterialName, density));
+ } else if ("lb/ft3".equals(unit)) {
+ materialMap.put(Databases.findMaterial(Material.Type.BULK, cleanedMaterialName, 16.0184634d * density));
+ } else if ("oz/in".equals(unit)) {
+ materialMap.put(Databases.findMaterial(Material.Type.LINE, cleanedMaterialName, 1.11612296d * density));
+ } else if ("oz/in2".equals(unit)) {
+ materialMap.put(Databases.findMaterial(Material.Type.SURFACE, cleanedMaterialName, 43.94184876d * density));
} else {
throw new BugException("Unknown unit in Materials file: " + unit);
}
}
-
+
}
\ No newline at end of file
package net.sf.openrocket.preset.loader;
+import net.sf.openrocket.database.Databases;
import net.sf.openrocket.material.Material;
import net.sf.openrocket.preset.TypedKey;
import net.sf.openrocket.preset.TypedPropertyMap;
public class SurfaceMaterialColumnParser extends BaseColumnParser {
-
+
private final MaterialHolder materialMap;
-
+
private final TypedKey<Material> param;
public SurfaceMaterialColumnParser(MaterialHolder materialMap, String columnName, TypedKey<Material> param) {
this.materialMap = materialMap;
}
-
+
@Override
protected void doParse(String columnData, String[] data, TypedPropertyMap props) {
-
- if ( columnData == null || "".equals(columnData.trim())) {
+
+ if (columnData == null || "".equals(columnData.trim())) {
return;
}
- Material.Surface myMaterial = (Material.Surface) Material.newUserMaterial(Material.Type.SURFACE,columnData, 0.0);
+ Material.Surface myMaterial = (Material.Surface) Databases.findMaterial(Material.Type.SURFACE, columnData, 0.0);
Material.Surface m = materialMap.getSurfaceMaterial(myMaterial, null);
- props.put(param, m!=null ? m : myMaterial);
-
+ props.put(param, m != null ? m : myMaterial);
+
}
-
+
}
-
package net.sf.openrocket.preset.xml;
-import net.sf.openrocket.database.Databases;
-import net.sf.openrocket.material.Material;
-import net.sf.openrocket.motor.Manufacturer;
-import net.sf.openrocket.preset.ComponentPreset;
-import net.sf.openrocket.preset.InvalidComponentPresetException;
-import net.sf.openrocket.preset.TypedPropertyMap;
-import net.sf.openrocket.unit.UnitGroup;
+import java.awt.image.BufferedImage;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.List;
import javax.imageio.ImageIO;
import javax.xml.bind.DatatypeConverter;
import javax.xml.bind.annotation.XmlValue;
import javax.xml.bind.annotation.adapters.XmlAdapter;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
-import java.awt.image.BufferedImage;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.util.List;
+
+import net.sf.openrocket.database.Databases;
+import net.sf.openrocket.material.Material;
+import net.sf.openrocket.motor.Manufacturer;
+import net.sf.openrocket.preset.ComponentPreset;
+import net.sf.openrocket.preset.InvalidComponentPresetException;
+import net.sf.openrocket.preset.TypedPropertyMap;
+import net.sf.openrocket.unit.UnitGroup;
/**
* Base class for the external representation of all component presets.
*/
@XmlAccessorType(XmlAccessType.FIELD)
public abstract class BaseComponentDTO {
-
+
@XmlElement(name = "Manufacturer")
private String manufacturer;
@XmlElement(name = "PartNumber")
private AnnotatedMaterialDTO material;
@XmlElement(name = "Mass")
private AnnotatedMassDTO mass;
- @XmlElement(name="Filled")
+ @XmlElement(name = "Filled")
private Boolean filled;
- @XmlInlineBinaryData
- @XmlJavaTypeAdapter(Base64Adapter.class)
- @XmlElement(name = "Thumbnail")
- private byte[] image;
-
+ @XmlInlineBinaryData
+ @XmlJavaTypeAdapter(Base64Adapter.class)
+ @XmlElement(name = "Thumbnail")
+ private byte[] image;
+
/**
* Default constructor.
*/
protected BaseComponentDTO() {
}
-
+
/**
* Constructor.
*
protected BaseComponentDTO(final ComponentPreset preset) {
setManufacturer(preset.getManufacturer().getSimpleName());
setPartNo(preset.getPartNo());
- if ( preset.has(ComponentPreset.DESCRIPTION )) {
+ if (preset.has(ComponentPreset.DESCRIPTION)) {
setDescription(preset.get(ComponentPreset.DESCRIPTION));
}
- if ( preset.has(ComponentPreset.MATERIAL)) {
+ if (preset.has(ComponentPreset.MATERIAL)) {
setMaterial(new AnnotatedMaterialDTO(preset.get(ComponentPreset.MATERIAL)));
}
if (preset.has(ComponentPreset.MASS)) {
setMass(preset.get(ComponentPreset.MASS));
}
- if ( preset.has(ComponentPreset.FILLED) ) {
- setFilled( preset.get(ComponentPreset.FILLED));
+ if (preset.has(ComponentPreset.FILLED)) {
+ setFilled(preset.get(ComponentPreset.FILLED));
+ }
+ if (preset.has(ComponentPreset.IMAGE)) {
+ setImageData(preset.get(ComponentPreset.IMAGE));
}
- if (preset.has(ComponentPreset.IMAGE) ) {
- setImageData(preset.get(ComponentPreset.IMAGE));
- }
}
-
+
public String getManufacturer() {
return manufacturer;
}
-
+
public void setManufacturer(final String theManufacturer) {
manufacturer = theManufacturer;
}
-
+
public String getPartNo() {
return partNo;
}
-
+
public void setPartNo(final String thePartNo) {
partNo = thePartNo;
}
-
+
public String getDescription() {
return description;
}
-
+
public void setDescription(final String theDescription) {
description = theDescription;
}
-
+
public AnnotatedMaterialDTO getMaterial() {
return material;
}
-
+
public void setMaterial(final AnnotatedMaterialDTO theMaterial) {
material = theMaterial;
}
-
+
public double getMass() {
return mass.getValue();
}
-
+
public void setMass(final AnnotatedMassDTO theMass) {
mass = theMass;
}
-
+
public void setMass(final double theMass) {
mass = new AnnotatedMassDTO(theMass);
}
-
+
public Boolean getFilled() {
return filled;
}
-
+
public void setFilled(Boolean filled) {
this.filled = filled;
}
-
- public byte[] getImageData() {
- return image;
- }
-
- public void setImageData(final byte[] theImage) {
- image = theImage;
- }
-
- public BufferedImage getImage() throws IOException {
- if (image != null) {
- return ImageIO.read(new ByteArrayInputStream(image));
- }
- return null;
- }
-
- public void setImage(BufferedImage theImage) throws IOException {
- if (theImage != null) {
- final ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
- ImageIO.write(theImage, "png", byteArrayOutputStream);
- image = byteArrayOutputStream.toByteArray();
- }
- }
-
- public abstract ComponentPreset asComponentPreset(List<MaterialDTO> materials) throws InvalidComponentPresetException;
-
+
+ public byte[] getImageData() {
+ return image;
+ }
+
+ public void setImageData(final byte[] theImage) {
+ image = theImage;
+ }
+
+ public BufferedImage getImage() throws IOException {
+ if (image != null) {
+ return ImageIO.read(new ByteArrayInputStream(image));
+ }
+ return null;
+ }
+
+ public void setImage(BufferedImage theImage) throws IOException {
+ if (theImage != null) {
+ final ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ ImageIO.write(theImage, "png", byteArrayOutputStream);
+ image = byteArrayOutputStream.toByteArray();
+ }
+ }
+
+ public abstract ComponentPreset asComponentPreset(List<MaterialDTO> materials) throws InvalidComponentPresetException;
+
void addProps(TypedPropertyMap props, List<MaterialDTO> materialList) {
props.put(ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer(manufacturer));
props.put(ComponentPreset.PARTNO, partNo);
- if ( description != null ) {
+ if (description != null) {
props.put(ComponentPreset.DESCRIPTION, description);
}
Material m = find(materialList, material);
- if ( m != null ) {
+ if (m != null) {
props.put(ComponentPreset.MATERIAL, find(materialList, material));
}
- if ( mass != null ) {
+ if (mass != null) {
props.put(ComponentPreset.MASS, getMass());
}
- if ( filled != null ) {
+ if (filled != null) {
props.put(ComponentPreset.FILLED, getFilled());
}
- if (image != null) {
- props.put(ComponentPreset.IMAGE, image);
- }
+ if (image != null) {
+ props.put(ComponentPreset.IMAGE, image);
+ }
}
-
+
protected Material find(List<MaterialDTO> materialList, AnnotatedMaterialDTO dto) {
- if ( dto == null ) {
+ if (dto == null) {
return null;
}
for (int i = 0; i < materialList.size(); i++) {
- MaterialDTO materialDTO = materialList.get(i);
+ MaterialDTO materialDTO = materialList.get(i);
if (materialDTO.getType().name().equals(dto.type) && materialDTO.getName().equals(dto.material)) {
return materialDTO.asMaterial();
}
}
-
+
// Don't have one, first check OR's database
- Material m = Databases.findMaterial(dto.getORMaterialType(), dto.material);
- if ( m != null ) {
- return m;
- }
-
- return Material.newUserMaterial(dto.getORMaterialType(), dto.material, 0.0);
-
+ Material m = Databases.findMaterial(dto.getORMaterialType(), dto.material);
+ if (m != null) {
+ return m;
+ }
+
+ return Databases.findMaterial(dto.getORMaterialType(), dto.material, 0.0);
+
}
-
+
static class AnnotatedMaterialDTO {
@XmlAttribute(name = "Type")
private String type;
@XmlValue
private String material;
-
- AnnotatedMaterialDTO() {}
-
+
+ AnnotatedMaterialDTO() {
+ }
+
AnnotatedMaterialDTO(Material theMaterial) {
type = theMaterial.getType().name();
material = theMaterial.getName();
}
public Material.Type getORMaterialType() {
- if ( "BULK".equals(type) ) {
+ if ("BULK".equals(type)) {
return Material.Type.BULK;
- } else if ( "SURFACE".equals(type) ) {
+ } else if ("SURFACE".equals(type)) {
return Material.Type.SURFACE;
- } else if ( "LINE".equals(type) ) {
+ } else if ("LINE".equals(type)) {
return Material.Type.LINE;
}
- throw new IllegalArgumentException( "Inavlid material type " + type +" specified for Component" );
+ throw new IllegalArgumentException("Inavlid material type " + type + " specified for Component");
}
}
-
+
static class AnnotatedLengthDTO {
- @XmlAttribute(name="Unit", required=false)
+ @XmlAttribute(name = "Unit", required = false)
private String unitName = "m";
@XmlValue
private double length;
-
- AnnotatedLengthDTO() {}
-
- AnnotatedLengthDTO( double length ) {
+
+ AnnotatedLengthDTO() {
+ }
+
+ AnnotatedLengthDTO(double length) {
this.length = length;
}
-
+
public double getValue() {
return UnitGroup.UNITS_LENGTH.getUnit(unitName).fromUnit(length);
}
}
-
+
static class AnnotatedMassDTO {
- @XmlAttribute(name="Unit", required=false)
+ @XmlAttribute(name = "Unit", required = false)
private String unitName = "kg";
@XmlValue
private double mass;
-
- AnnotatedMassDTO() {}
-
- AnnotatedMassDTO( double mass ) {
+
+ AnnotatedMassDTO() {
+ }
+
+ AnnotatedMassDTO(double mass) {
this.mass = mass;
}
-
+
public double getValue() {
return UnitGroup.UNITS_MASS.getUnit(unitName).fromUnit(mass);
}
}
-
- static class Base64Adapter extends XmlAdapter<String, byte[]> {
- @Override
- public byte[] unmarshal(String s) {
- if (s == null) {
- return null;
- }
- return DatatypeConverter.parseBase64Binary(s);
- }
-
- @Override
- public String marshal(byte[] bytes) {
- if (bytes == null) {
- return null;
- }
- return DatatypeConverter.printBase64Binary(bytes);
- }
- }
+
+ static class Base64Adapter extends XmlAdapter<String, byte[]> {
+ @Override
+ public byte[] unmarshal(String s) {
+ if (s == null) {
+ return null;
+ }
+ return DatatypeConverter.parseBase64Binary(s);
+ }
+
+ @Override
+ public String marshal(byte[] bytes) {
+ if (bytes == null) {
+ return null;
+ }
+ return DatatypeConverter.printBase64Binary(bytes);
+ }
+ }
}
-
package net.sf.openrocket.preset.xml;
import javax.xml.bind.Marshaller;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
+import net.sf.openrocket.database.Databases;
import net.sf.openrocket.material.Material;
import net.sf.openrocket.util.Chars;
@XmlRootElement(name = "Material")
@XmlAccessorType(XmlAccessType.FIELD)
public class MaterialDTO {
-
- @XmlElement(name = "Name")
- private String name;
- @XmlElement(name = "Density")
- private double density;
- @XmlElement(name = "Type")
- private MaterialTypeDTO type;
- @XmlAttribute(name = "UnitsOfMeasure")
- private String uom;
-
- /**
- * Default constructor.
- */
- public MaterialDTO() {
- }
-
- public MaterialDTO(final Material theMaterial) {
- this(theMaterial.getName(), theMaterial.getDensity(), MaterialTypeDTO.asDTO(theMaterial.getType()),
- theMaterial.getType().getUnitGroup().getDefaultUnit().toString());
- }
-
- public MaterialDTO(final String theName, final double theDensity, final MaterialTypeDTO theType, final String theUom) {
- name = theName;
- density = theDensity;
- type = theType;
- uom = theUom;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(final String theName) {
- name = theName;
- }
-
- public double getDensity() {
- return density;
- }
-
- public void setDensity(final double theDensity) {
- density = theDensity;
- }
-
- public MaterialTypeDTO getType() {
- return type;
- }
-
- public void setType(final MaterialTypeDTO theType) {
- type = theType;
- }
-
- public String getUom() {
- return uom;
- }
-
- public void setUom(final String theUom) {
- uom = theUom;
- }
-
- Material asMaterial() {
- return Material.newUserMaterial(type.getORMaterialType(), name, density);
- }
-
-
- /**
- * Special directive to the JAXB system. After the object is parsed from xml,
- * we replace the '2' with Chars.SQUARED, and '3' with Chars.CUBED. Just the
- * opposite transformation as doen in beforeMarshal.
- * @param unmarshaller
- * @param parent
- */
- @SuppressWarnings("unused")
- private void afterUnmarshal( Unmarshaller unmarshaller, Object parent ) {
- if (uom != null) {
- uom = uom.replace('2', Chars.SQUARED);
- uom = uom.replace('3', Chars.CUBED);
- }
- }
-
- /**
- * Special directive to the JAXB system. Before the object is serialized into xml,
- * we strip out the special unicode characters for cubed and squared so they appear
- * as simple "3" and "2" chars. The reverse transformation is done in afterUnmarshal.
- * @param marshaller
- */
- @SuppressWarnings("unused")
- private void beforeMarshal( Marshaller marshaller ) {
- if (uom != null ) {
- uom = uom.replace(Chars.SQUARED, '2');
- uom = uom.replace(Chars.CUBED, '3');
- }
- }
+
+ @XmlElement(name = "Name")
+ private String name;
+ @XmlElement(name = "Density")
+ private double density;
+ @XmlElement(name = "Type")
+ private MaterialTypeDTO type;
+ @XmlAttribute(name = "UnitsOfMeasure")
+ private String uom;
+
+ /**
+ * Default constructor.
+ */
+ public MaterialDTO() {
+ }
+
+ public MaterialDTO(final Material theMaterial) {
+ this(theMaterial.getName(), theMaterial.getDensity(), MaterialTypeDTO.asDTO(theMaterial.getType()),
+ theMaterial.getType().getUnitGroup().getDefaultUnit().toString());
+ }
+
+ public MaterialDTO(final String theName, final double theDensity, final MaterialTypeDTO theType, final String theUom) {
+ name = theName;
+ density = theDensity;
+ type = theType;
+ uom = theUom;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(final String theName) {
+ name = theName;
+ }
+
+ public double getDensity() {
+ return density;
+ }
+
+ public void setDensity(final double theDensity) {
+ density = theDensity;
+ }
+
+ public MaterialTypeDTO getType() {
+ return type;
+ }
+
+ public void setType(final MaterialTypeDTO theType) {
+ type = theType;
+ }
+
+ public String getUom() {
+ return uom;
+ }
+
+ public void setUom(final String theUom) {
+ uom = theUom;
+ }
+
+ Material asMaterial() {
+ return Databases.findMaterial(type.getORMaterialType(), name, density);
+ }
+
+
+ /**
+ * Special directive to the JAXB system. After the object is parsed from xml,
+ * we replace the '2' with Chars.SQUARED, and '3' with Chars.CUBED. Just the
+ * opposite transformation as doen in beforeMarshal.
+ * @param unmarshaller
+ * @param parent
+ */
+ @SuppressWarnings("unused")
+ private void afterUnmarshal(Unmarshaller unmarshaller, Object parent) {
+ if (uom != null) {
+ uom = uom.replace('2', Chars.SQUARED);
+ uom = uom.replace('3', Chars.CUBED);
+ }
+ }
+
+ /**
+ * Special directive to the JAXB system. Before the object is serialized into xml,
+ * we strip out the special unicode characters for cubed and squared so they appear
+ * as simple "3" and "2" chars. The reverse transformation is done in afterUnmarshal.
+ * @param marshaller
+ */
+ @SuppressWarnings("unused")
+ private void beforeMarshal(Marshaller marshaller) {
+ if (uom != null) {
+ uom = uom.replace(Chars.SQUARED, '2');
+ uom = uom.replace(Chars.CUBED, '3');
+ }
+ }
}
import java.util.Set;\r
\r
import net.sf.openrocket.database.Databases;\r
-import net.sf.openrocket.l10n.Translator;\r
import net.sf.openrocket.material.Material;\r
import net.sf.openrocket.preset.ComponentPreset;\r
import net.sf.openrocket.rocketcomponent.BodyComponent;\r
import net.sf.openrocket.util.UniqueID;\r
\r
public abstract class Preferences {\r
-\r
+ \r
/*\r
* Well known string keys to preferences.\r
* There are other strings out there in the source as well.\r
\r
public static final String MOTOR_DIAMETER_FILTER = "MotorDiameterMatch";\r
public static final String MOTOR_HIDE_SIMILAR = "MotorHideSimilar";\r
-\r
+ \r
// Node names\r
public static final String PREFERRED_THRUST_CURVE_MOTOR_NODE = "preferredThrustCurveMotors";\r
-\r
+ \r
/*\r
* ******************************************************************************************\r
* \r
* Abstract methods which must be implemented by any derived class.\r
*/\r
- public abstract boolean getBoolean( String key, boolean defaultValue );\r
- public abstract void putBoolean( String key, boolean value );\r
-\r
- public abstract int getInt( String key, int defaultValue);\r
- public abstract void putInt( String key, int value );\r
-\r
- public abstract double getDouble( String key, double defaultValue );\r
- public abstract void putDouble( String key, double value );\r
-\r
- public abstract String getString( String key, String defaultValue );\r
- public abstract void putString( String key, String value );\r
+ public abstract boolean getBoolean(String key, boolean defaultValue);\r
+ \r
+ public abstract void putBoolean(String key, boolean value);\r
+ \r
+ public abstract int getInt(String key, int defaultValue);\r
+ \r
+ public abstract void putInt(String key, int value);\r
+ \r
+ public abstract double getDouble(String key, double defaultValue);\r
+ \r
+ public abstract void putDouble(String key, double value);\r
+ \r
+ public abstract String getString(String key, String defaultValue);\r
+ \r
+ public abstract void putString(String key, String value);\r
\r
/**\r
* Directory represents a way to collect multiple keys together. Implementors may\r
* @param defaultValue\r
* @return\r
*/\r
- public abstract String getString( String directory, String key, String defaultValue);\r
-\r
- public abstract void putString( String directory, String key, String value );\r
-\r
+ public abstract String getString(String directory, String key, String defaultValue);\r
+ \r
+ public abstract void putString(String directory, String key, String value);\r
+ \r
/*\r
* ******************************************************************************************\r
*/\r
putString(key, value.name());\r
}\r
}\r
-\r
+ \r
public Color getDefaultColor(Class<? extends RocketComponent> c) {\r
String color = get("componentColors", c, DEFAULT_COLORS);\r
if (color == null)\r
return;\r
putString("componentColors", c.getSimpleName(), stringifyColor(color));\r
}\r
-\r
-\r
+ \r
+ \r
/**\r
* Retrieve a Line style for the given component.\r
* @param c\r
String material = get("componentMaterials", componentClass, null);\r
if (material != null) {\r
try {\r
- Material m = Material.fromStorableString(material);\r
+ Material m = Material.fromStorableString(material, false);\r
if (m.getType() == type)\r
return m;\r
} catch (IllegalArgumentException ignore) {\r
putString("componentMaterials", componentClass.getSimpleName(),\r
material == null ? null : material.toStorableString());\r
}\r
-\r
+ \r
/**\r
* get a net.sf.openrocket.util.Color object for the given key.\r
* @param key\r
* @param defaultValue\r
* @return\r
*/\r
- public final Color getColor( String key, Color defaultValue ) {\r
- Color c = parseColor( getString(key,null) );\r
- if ( c == null ) {\r
+ public final Color getColor(String key, Color defaultValue) {\r
+ Color c = parseColor(getString(key, null));\r
+ if (c == null) {\r
return defaultValue;\r
}\r
return c;\r
* @param key\r
* @param value\r
*/\r
- public final void putColor( String key, Color value ) {\r
- putString( key, stringifyColor(value) );\r
+ public final void putColor(String key, Color value) {\r
+ putString(key, stringifyColor(value));\r
}\r
-\r
+ \r
/**\r
* Helper function to convert a string representation into a net.sf.openrocket.util.Color object.\r
* @param color\r
String string = color.getRed() + "," + color.getGreen() + "," + color.getBlue();\r
return string;\r
}\r
-\r
+ \r
/**\r
* Special helper function which allows for a map of default values.\r
* \r
\r
return null;\r
}\r
-\r
+ \r
public abstract void addUserMaterial(Material m);\r
+ \r
public abstract Set<Material> getUserMaterials();\r
+ \r
public abstract void removeUserMaterial(Material m);\r
-\r
- public abstract void setComponentFavorite( ComponentPreset preset, ComponentPreset.Type type, boolean favorite );\r
- public abstract Set<String> getComponentFavorites( ComponentPreset.Type type );\r
-\r
+ \r
+ public abstract void setComponentFavorite(ComponentPreset preset, ComponentPreset.Type type, boolean favorite);\r
+ \r
+ public abstract Set<String> getComponentFavorites(ComponentPreset.Type type);\r
+ \r
/*\r
* Map of default line styles\r
*/\r
* Within a holder class so they will load only when needed.\r
*/\r
private static class DefaultMaterialHolder {\r
- private static final Translator trans = Application.getTranslator();\r
- \r
- //// Elastic cord (round 2mm, 1/16 in)\r
- private static final Material DEFAULT_LINE_MATERIAL =\r
- Databases.findMaterial(Material.Type.LINE, "Elasticcordround2mm", trans.get("Databases.materials.Elasticcordround2mm"),0.0018);\r
- //// Ripstop nylon\r
- private static final Material DEFAULT_SURFACE_MATERIAL =\r
- Databases.findMaterial(Material.Type.SURFACE, "Ripstopnylon", trans.get("Databases.materials.Ripstopnylon"), 0.067);\r
- //// Cardboard\r
- private static final Material DEFAULT_BULK_MATERIAL =\r
- Databases.findMaterial(Material.Type.BULK, "Cardboard", trans.get("Databases.materials.Cardboard"), 680);\r
+ private static final Material DEFAULT_LINE_MATERIAL = Databases.findMaterial(Material.Type.LINE, "Elastic cord (round 2 mm, 1/16 in)");\r
+ private static final Material DEFAULT_SURFACE_MATERIAL = Databases.findMaterial(Material.Type.SURFACE, "Ripstop nylon");\r
+ private static final Material DEFAULT_BULK_MATERIAL = Databases.findMaterial(Material.Type.BULK, "Cardboard");\r
}\r
\r
private static final HashMap<Class<?>, String> DEFAULT_COLORS =\r
DEFAULT_COLORS.put(RecoveryDevice.class, "255,0,0");\r
}\r
\r
-\r
-\r
+ \r
+ \r
}\r
import java.util.Random;
+import net.sf.openrocket.database.Databases;
import net.sf.openrocket.material.Material;
import net.sf.openrocket.material.Material.Type;
import net.sf.openrocket.motor.Motor;
rocket.setRevision("Rocket revision " + key);
rocket.setName(key);
-
+
Stage stage = new Stage();
setBasics(stage);
rocket.addChild(stage);
-
+
NoseCone nose = new NoseCone();
setBasics(stage);
nose.setAftRadius(rnd(0.03));
nose.setType((Shape) randomEnum(Shape.class));
stage.addChild(nose);
-
+
Transition shoulder = new Transition();
setBasics(shoulder);
shoulder.setAftRadius(rnd(0.06));
shoulder.setType((Shape) randomEnum(Shape.class));
stage.addChild(shoulder);
-
+
BodyTube body = new BodyTube();
setBasics(body);
body.setThickness(rnd(0.002));
body.setOuterRadiusAutomatic(rnd.nextBoolean());
stage.addChild(body);
-
+
Transition boattail = new Transition();
setBasics(boattail);
boattail.setAftRadius(rnd(0.03));
boattail.setType((Shape) randomEnum(Shape.class));
stage.addChild(boattail);
-
+
MassComponent mass = new MassComponent();
setBasics(mass);
mass.setComponentMass(rnd(0.05));
mass.setRadius(rnd(0.05));
nose.addChild(mass);
-
-
-
+
+
+
return rocket;
}
ExternalComponent e = (ExternalComponent) c;
e.setFinish((Finish) randomEnum(Finish.class));
double d = rnd(100);
- e.setMaterial(Material.newUserMaterial(Type.BULK, "Testmat " + d, d));
+ e.setMaterial(Databases.findMaterial(Type.BULK, "Testmat " + d, d));
}
if (c instanceof InternalComponent) {
}
-
+
private double rnd(double scale) {
return (rnd.nextDouble() * 0.2 + 0.9) * scale;
}
}
-
-
-
+
+
+
public Rocket makeSmallFlyable() {
double noseconeLength = 0.10, noseconeRadius = 0.01;
double bodytubeLength = 0.20, bodytubeRadius = 0.01, bodytubeThickness = 0.001;
int finCount = 3;
double finRootChord = 0.04, finTipChord = 0.05, finSweep = 0.01, finThickness = 0.003, finHeight = 0.03;
-
+
Rocket rocket;
Stage stage;
NoseCone nosecone;
finset = new TrapezoidFinSet(finCount, finRootChord, finTipChord, finSweep, finHeight);
-
+
// Stage construction
rocket.addChild(stage);
-
+
// Component construction
stage.addChild(nosecone);
stage.addChild(bodytube);
rocket.getDefaultConfiguration().setAllStages();
-
+
return rocket;
}
rocket.addChild(stage);
rocket.setPerfectFinish(false);
-
+
// Component construction
stage.addChild(nosecone);
stage.addChild(bodytube);
rocket.getDefaultConfiguration().setAllStages();
-
+
return rocket;
}
-
+
public static Rocket makeIsoHaisu() {
Rocket rocket;
Stage stage;
tube3.setOverrideMass(0.730);
stage.addChild(tube3);
-
+
LaunchLug lug = new LaunchLug();
tube1.addChild(lug);
coupler.setPositionValue(-0.14);
tube1.addChild(coupler);
-
+
// Parachute
MassComponent mass = new MassComponent(0.05, 0.05, 0.280);
mass.setRelativePosition(Position.TOP);
mass.setPositionValue(0.25);
tube1.addChild(mass);
-
+
auxfinset = new TrapezoidFinSet();
auxfinset.setName("CONTROL");
auxfinset.setFinCount(2);
auxfinset.setBaseRotation(Math.PI / 2);
tube1.addChild(auxfinset);
-
-
-
+
+
+
coupler = new TubeCoupler();
coupler.setOuterRadiusAutomatic(true);
coupler.setLength(0.28);
coupler.setOverrideMass(0.360);
tube2.addChild(coupler);
-
-
+
+
// Parachute
mass = new MassComponent(0.1, 0.05, 0.028);
mass.setRelativePosition(Position.TOP);
mass.setPositionValue(0.19);
tube2.addChild(mass);
-
-
+
+
InnerTube inner = new InnerTube();
inner.setOuterRadius(0.08 / 2);
inner.setInnerRadius(0.0762 / 2);
inner.setOverrideMass(0.388);
tube3.addChild(inner);
-
+
CenteringRing center = new CenteringRing();
center.setInnerRadiusAutomatic(true);
center.setOuterRadiusAutomatic(true);
center.setPositionValue(0);
tube3.addChild(center);
-
+
center = new CenteringRing();
center.setInnerRadiusAutomatic(true);
center.setOuterRadiusAutomatic(true);
center.setPositionValue(0.28);
tube3.addChild(center);
-
+
center = new CenteringRing();
center.setInnerRadiusAutomatic(true);
center.setOuterRadiusAutomatic(true);
center.setPositionValue(0.83);
tube3.addChild(center);
-
-
-
-
+
+
+
+
finset = new TrapezoidFinSet();
finset.setRootChord(0.495);
finset.setTipChord(0.1);
finset.setBaseRotation(Math.PI / 2);
tube3.addChild(finset);
-
+
finset.setCantAngle(0 * Math.PI / 180);
System.err.println("Fin cant angle: " + (finset.getCantAngle() * 180 / Math.PI));
-
+
// Stage construction
rocket.addChild(stage);
rocket.setPerfectFinish(false);
-
-
+
+
String id = rocket.newMotorConfigurationID();
tube3.setMotorMount(true);
rocket.getDefaultConfiguration().setAllStages();
-
+
return rocket;
}
-
-
+
+
}
--- /dev/null
+package net.sf.openrocket.l10n;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+
+public class TestDebugTranslator {
+
+ @Test
+ public void testGetEnglish() {
+ DebugTranslator trans = new DebugTranslator(null);
+ assertEquals("[material:Paper (office)]", trans.get("material", "Paper (office)"));
+ }
+
+
+ @Test
+ public void testGetBase() {
+ DebugTranslator trans = new DebugTranslator(null);
+ assertEquals("Paper (office)", trans.getBaseText("material", "[material:Paper (office)]"));
+ assertEquals("Papier (toilet)", trans.getBaseText("material", "Papier (toilet)"));
+ }
+
+
+}
--- /dev/null
+package net.sf.openrocket.l10n;
+
+import static org.junit.Assert.assertEquals;
+import net.sf.openrocket.util.Chars;
+
+import org.junit.Test;
+
+public class TestL10N {
+
+ @Test
+ public void testNormalize() {
+ assertEquals("hello", L10N.normalize("hello"));
+ assertEquals("hello", L10N.normalize("Hello"));
+ assertEquals("hello", L10N.normalize(" \t Hello \n "));
+ assertEquals("hello", L10N.normalize("H\u00eall\u00d6"));
+ assertEquals("hello_world", L10N.normalize("Hello World!"));
+ assertEquals("hello_world", L10N.normalize("? Hello\nWorld !"));
+ assertEquals("hello_123", L10N.normalize("Hello 123!"));
+ assertEquals("hello_123", L10N.normalize("Hello/123?"));
+
+ assertEquals("plywood_birch", L10N.normalize("Plywood (birch)"));
+ assertEquals("styrofoam_blue_foam_xps", L10N.normalize("Styrofoam \"Blue foam\" (XPS)"));
+ assertEquals("tubular_nylon_11_mm_7_16_in", L10N.normalize("Tubular nylon (11 mm, 7/16 in)"));
+
+ assertEquals("m2", L10N.normalize("m" + Chars.SQUARED));
+ assertEquals("a_b", L10N.normalize("a" + Chars.NBSP + "b"));
+ assertEquals("1_2a", L10N.normalize(Chars.FRAC12 + "A"));
+
+ }
+}
import java.util.Locale;
import java.util.MissingResourceException;
+import org.junit.After;
+import org.junit.Before;
import org.junit.Test;
public class TestResourceBundleTranslator {
+ private Locale originalDefaultLocale;
+
+ @Before
+ public void setup() {
+ // Default locale affects resource bundles, so set something non-English
+ this.originalDefaultLocale = Locale.getDefault();
+ Locale.setDefault(Locale.GERMAN);
+ }
+
+ @After
+ public void teardown() {
+ Locale.setDefault(originalDefaultLocale);
+ }
+
+
@Test
- public void testSuccessfulUS() {
- ResourceBundleTranslator trans = new ResourceBundleTranslator("l10n.messages", Locale.US);
- assertEquals("messages.properties", trans.get("debug.currentFile"));
+ public void testSuccessfulDefault() {
+ ResourceBundleTranslator trans = new ResourceBundleTranslator("l10n.messages");
+ assertEquals("messages_de.properties", trans.get("debug.currentFile"));
}
@Test
- public void testSuccessfulFR() {
+ public void testSuccessfulNonDefault() {
ResourceBundleTranslator trans = new ResourceBundleTranslator("l10n.messages", Locale.FRENCH);
assertEquals("messages_fr.properties", trans.get("debug.currentFile"));
}
}
}
+ @Test
+ public void testGetEnglish() {
+ ResourceBundleTranslator trans = new ResourceBundleTranslator("l10n.messages", Locale.FRENCH);
+ assertEquals("Papier (bureau)", trans.get("material", "Paper (office)"));
+ assertEquals("Paper (toilet)", trans.get("material", "Paper (toilet)"));
+ }
+
+
+ @Test
+ public void testGetBase() {
+ ResourceBundleTranslator trans = new ResourceBundleTranslator("l10n.messages", Locale.FRENCH);
+ assertEquals("Paper (office)", trans.getBaseText("material", "Papier (bureau)"));
+ assertEquals("Papier (toilet)", trans.getBaseText("material", "Papier (toilet)"));
+ }
+
+
}
*
*/
public class BodyTubeComponentTests extends BaseTestCase {
-
+
ComponentPreset preset;
@Before
public void createPreset() throws Exception {
TypedPropertyMap presetspec = new TypedPropertyMap();
presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.BODY_TUBE);
- presetspec.put( ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
- presetspec.put( ComponentPreset.PARTNO, "partno");
- presetspec.put( ComponentPreset.LENGTH, 2.0);
- presetspec.put( ComponentPreset.OUTER_DIAMETER, 2.0);
- presetspec.put( ComponentPreset.INNER_DIAMETER, 1.0);
- presetspec.put( ComponentPreset.MASS, 100.0);
+ presetspec.put(ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
+ presetspec.put(ComponentPreset.PARTNO, "partno");
+ presetspec.put(ComponentPreset.LENGTH, 2.0);
+ presetspec.put(ComponentPreset.OUTER_DIAMETER, 2.0);
+ presetspec.put(ComponentPreset.INNER_DIAMETER, 1.0);
+ presetspec.put(ComponentPreset.MASS, 100.0);
preset = ComponentPresetFactory.create(presetspec);
}
-
+
@Test
public void testComponentType() {
BodyTube bt = new BodyTube();
- assertSame( ComponentPreset.Type.BODY_TUBE, bt.getPresetType() );
+ assertSame(ComponentPreset.Type.BODY_TUBE, bt.getPresetType());
}
@Test
bt.loadPreset(preset);
- assertEquals( 2.0, bt.getLength(), 0.0 );
- assertEquals( 1.0, bt.getOuterRadius(), 0.0 );
- assertEquals( 1.0, bt.getAftRadius(), 0.0 );
- assertEquals( 0.5, bt.getInnerRadius(), 0.0 );
+ assertEquals(2.0, bt.getLength(), 0.0);
+ assertEquals(1.0, bt.getOuterRadius(), 0.0);
+ assertEquals(1.0, bt.getAftRadius(), 0.0);
+ assertEquals(0.5, bt.getInnerRadius(), 0.0);
- assertFalse( bt.isAftRadiusAutomatic() );
- assertFalse( bt.isFilled() );
- assertFalse( bt.isForeRadiusAutomatic() );
- assertFalse( bt.isOuterRadiusAutomatic() );
+ assertFalse(bt.isAftRadiusAutomatic());
+ assertFalse(bt.isFilled());
+ assertFalse(bt.isForeRadiusAutomatic());
+ assertFalse(bt.isOuterRadiusAutomatic());
- assertSame( preset.get( ComponentPreset.MATERIAL), bt.getMaterial() );
- assertEquals( 100.0, bt.getMass(), 0.05);
+ assertSame(preset.get(ComponentPreset.MATERIAL), bt.getMaterial());
+ assertEquals(100.0, bt.getMass(), 0.05);
}
@Test
BodyTube bt = new BodyTube();
bt.loadPreset(preset);
-
+
bt.setLength(1.0);
- assertSame( preset, bt.getPresetComponent() );
+ assertSame(preset, bt.getPresetComponent());
}
-
+
@Test
public void changeODClearsPreset() {
BodyTube bt = new BodyTube();
bt.loadPreset(preset);
-
+
bt.setOuterRadius(2.0);
- assertNull( bt.getPresetComponent() );
+ assertNull(bt.getPresetComponent());
}
-
+
@Test
public void changeIDClearsPreset() {
BodyTube bt = new BodyTube();
bt.loadPreset(preset);
-
+
bt.setInnerRadius(0.75);
- assertNull( bt.getPresetComponent() );
+ assertNull(bt.getPresetComponent());
}
-
+
@Test
public void changeThicknessClearsPreset() {
BodyTube bt = new BodyTube();
bt.loadPreset(preset);
-
+
bt.setThickness(0.1);
- assertNull( bt.getPresetComponent() );
+ assertNull(bt.getPresetComponent());
}
-
+
@Test
public void changeMaterialClearsPreset() {
BodyTube bt = new BodyTube();
bt.loadPreset(preset);
-
- bt.setMaterial( Material.newUserMaterial(Material.Type.BULK,"new", 1.0));
- assertNull( bt.getPresetComponent() );
+ bt.setMaterial(Material.newMaterial(Material.Type.BULK, "new", 1.0, true));
+
+ assertNull(bt.getPresetComponent());
}
-
+
@Test
public void changeFinishLeavesPreset() {
BodyTube bt = new BodyTube();
bt.loadPreset(preset);
-
- bt.setFinish( Finish.POLISHED );
- assertSame( preset, bt.getPresetComponent() );
+ bt.setFinish(Finish.POLISHED);
+
+ assertSame(preset, bt.getPresetComponent());
}
-
+
@Test
public void changeFillClearsPreset() {
BodyTube bt = new BodyTube();
bt.loadPreset(preset);
-
- bt.setFilled( true );
- assertNull( bt.getPresetComponent() );
+ bt.setFilled(true);
+
+ assertNull(bt.getPresetComponent());
}
}
*
*/
public class BodyTubePresetTests {
-
+
@Test
public void testManufacturerRequired() {
try {
TypedPropertyMap presetspec = new TypedPropertyMap();
presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.BODY_TUBE);
ComponentPresetFactory.create(presetspec);
- } catch ( InvalidComponentPresetException ex ) {
- PresetAssertHelper.assertInvalidPresetException( ex,
+ } catch (InvalidComponentPresetException ex) {
+ PresetAssertHelper.assertInvalidPresetException(ex,
new TypedKey<?>[] {
- ComponentPreset.MANUFACTURER,
- ComponentPreset.PARTNO,
- ComponentPreset.LENGTH
- },
- new String[] {
- "No Manufacturer specified",
- "No PartNo specified",
- "No Length specified",
- "Preset dimensions underspecified"
- }
+ ComponentPreset.MANUFACTURER,
+ ComponentPreset.PARTNO,
+ ComponentPreset.LENGTH
+ },
+ new String[] {
+ "No Manufacturer specified",
+ "No PartNo specified",
+ "No Length specified",
+ "Preset dimensions underspecified"
+ }
);
}
}
-
+
@Test
public void testPartNoRequired() {
try {
TypedPropertyMap presetspec = new TypedPropertyMap();
presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.BODY_TUBE);
- presetspec.put( ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
+ presetspec.put(ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
ComponentPresetFactory.create(presetspec);
- } catch ( InvalidComponentPresetException ex ) {
- PresetAssertHelper.assertInvalidPresetException( ex,
+ } catch (InvalidComponentPresetException ex) {
+ PresetAssertHelper.assertInvalidPresetException(ex,
new TypedKey<?>[] {
- ComponentPreset.PARTNO,
- ComponentPreset.LENGTH
- },
- new String[] {
- "No PartNo specified",
- "No Length specified",
- "Preset dimensions underspecified"
- }
+ ComponentPreset.PARTNO,
+ ComponentPreset.LENGTH
+ },
+ new String[] {
+ "No PartNo specified",
+ "No Length specified",
+ "Preset dimensions underspecified"
+ }
);
}
}
-
+
@Test
public void testLengthRequired() {
try {
TypedPropertyMap presetspec = new TypedPropertyMap();
presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.BODY_TUBE);
- presetspec.put( ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
- presetspec.put( ComponentPreset.PARTNO, "partno");
+ presetspec.put(ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
+ presetspec.put(ComponentPreset.PARTNO, "partno");
ComponentPresetFactory.create(presetspec);
- } catch ( InvalidComponentPresetException ex ) {
- PresetAssertHelper.assertInvalidPresetException( ex,
+ } catch (InvalidComponentPresetException ex) {
+ PresetAssertHelper.assertInvalidPresetException(ex,
new TypedKey<?>[] {
ComponentPreset.LENGTH
- },
- new String[] {
- "No Length specified",
- "Preset dimensions underspecified"
- }
+ },
+ new String[] {
+ "No Length specified",
+ "Preset dimensions underspecified"
+ }
);
}
}
-
+
@Test
public void testOnlyOuterDiameter() {
try {
TypedPropertyMap presetspec = new TypedPropertyMap();
presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.BODY_TUBE);
- presetspec.put( ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
- presetspec.put( ComponentPreset.PARTNO, "partno");
- presetspec.put( ComponentPreset.LENGTH, 2.0);
- presetspec.put( ComponentPreset.OUTER_DIAMETER, 2.0);
+ presetspec.put(ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
+ presetspec.put(ComponentPreset.PARTNO, "partno");
+ presetspec.put(ComponentPreset.LENGTH, 2.0);
+ presetspec.put(ComponentPreset.OUTER_DIAMETER, 2.0);
ComponentPresetFactory.create(presetspec);
- } catch ( InvalidComponentPresetException ex ) {
- PresetAssertHelper.assertInvalidPresetException( ex,
+ } catch (InvalidComponentPresetException ex) {
+ PresetAssertHelper.assertInvalidPresetException(ex,
null,
- new String[] {
+ new String[] {
"Preset dimensions underspecified"
- }
+ }
);
}
}
-
+
@Test
public void testOnlyInnerDiameter() {
try {
TypedPropertyMap presetspec = new TypedPropertyMap();
presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.BODY_TUBE);
- presetspec.put( ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
- presetspec.put( ComponentPreset.PARTNO, "partno");
- presetspec.put( ComponentPreset.LENGTH, 2.0);
- presetspec.put( ComponentPreset.INNER_DIAMETER, 2.0);
+ presetspec.put(ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
+ presetspec.put(ComponentPreset.PARTNO, "partno");
+ presetspec.put(ComponentPreset.LENGTH, 2.0);
+ presetspec.put(ComponentPreset.INNER_DIAMETER, 2.0);
ComponentPresetFactory.create(presetspec);
- } catch ( InvalidComponentPresetException ex ) {
- PresetAssertHelper.assertInvalidPresetException( ex,
+ } catch (InvalidComponentPresetException ex) {
+ PresetAssertHelper.assertInvalidPresetException(ex,
null,
- new String[] {
+ new String[] {
"Preset dimensions underspecified"
- }
+ }
);
}
}
-
+
@Test
public void testOnlyThicknessDiameter() {
try {
TypedPropertyMap presetspec = new TypedPropertyMap();
presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.BODY_TUBE);
- presetspec.put( ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
- presetspec.put( ComponentPreset.PARTNO, "partno");
- presetspec.put( ComponentPreset.LENGTH, 2.0);
- presetspec.put( ComponentPreset.THICKNESS, 2.0);
+ presetspec.put(ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
+ presetspec.put(ComponentPreset.PARTNO, "partno");
+ presetspec.put(ComponentPreset.LENGTH, 2.0);
+ presetspec.put(ComponentPreset.THICKNESS, 2.0);
ComponentPresetFactory.create(presetspec);
- } catch ( InvalidComponentPresetException ex ) {
- PresetAssertHelper.assertInvalidPresetException( ex,
+ } catch (InvalidComponentPresetException ex) {
+ PresetAssertHelper.assertInvalidPresetException(ex,
null,
- new String[] {
+ new String[] {
"Preset dimensions underspecified"
- }
+ }
);
}
}
-
+
@Test
public void testComputeInnerDiameter() throws Exception {
TypedPropertyMap presetspec = new TypedPropertyMap();
presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.BODY_TUBE);
- presetspec.put( ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
- presetspec.put( ComponentPreset.PARTNO, "partno");
- presetspec.put( ComponentPreset.LENGTH, 2.0);
- presetspec.put( ComponentPreset.OUTER_DIAMETER, 2.0);
- presetspec.put( ComponentPreset.THICKNESS, 0.5);
+ presetspec.put(ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
+ presetspec.put(ComponentPreset.PARTNO, "partno");
+ presetspec.put(ComponentPreset.LENGTH, 2.0);
+ presetspec.put(ComponentPreset.OUTER_DIAMETER, 2.0);
+ presetspec.put(ComponentPreset.THICKNESS, 0.5);
ComponentPreset preset = ComponentPresetFactory.create(presetspec);
-
- assertEquals(1.0,preset.get(ComponentPreset.INNER_DIAMETER).doubleValue(),0.0);
+
+ assertEquals(1.0, preset.get(ComponentPreset.INNER_DIAMETER).doubleValue(), 0.0);
}
-
+
@Test
public void testComputeOuterDiameter() throws Exception {
TypedPropertyMap presetspec = new TypedPropertyMap();
presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.BODY_TUBE);
- presetspec.put( ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
- presetspec.put( ComponentPreset.PARTNO, "partno");
- presetspec.put( ComponentPreset.LENGTH, 2.0);
- presetspec.put( ComponentPreset.INNER_DIAMETER, 1.0);
- presetspec.put( ComponentPreset.THICKNESS, 0.5);
+ presetspec.put(ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
+ presetspec.put(ComponentPreset.PARTNO, "partno");
+ presetspec.put(ComponentPreset.LENGTH, 2.0);
+ presetspec.put(ComponentPreset.INNER_DIAMETER, 1.0);
+ presetspec.put(ComponentPreset.THICKNESS, 0.5);
ComponentPreset preset = ComponentPresetFactory.create(presetspec);
-
- assertEquals(2.0,preset.get(ComponentPreset.OUTER_DIAMETER).doubleValue(),0.0);
+
+ assertEquals(2.0, preset.get(ComponentPreset.OUTER_DIAMETER).doubleValue(), 0.0);
}
-
+
@Test
public void testComputeThickness() throws Exception {
TypedPropertyMap presetspec = new TypedPropertyMap();
presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.BODY_TUBE);
- presetspec.put( ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
- presetspec.put( ComponentPreset.PARTNO, "partno");
- presetspec.put( ComponentPreset.LENGTH, 2.0);
- presetspec.put( ComponentPreset.OUTER_DIAMETER, 2.0);
- presetspec.put( ComponentPreset.INNER_DIAMETER, 1.0);
+ presetspec.put(ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
+ presetspec.put(ComponentPreset.PARTNO, "partno");
+ presetspec.put(ComponentPreset.LENGTH, 2.0);
+ presetspec.put(ComponentPreset.OUTER_DIAMETER, 2.0);
+ presetspec.put(ComponentPreset.INNER_DIAMETER, 1.0);
ComponentPreset preset = ComponentPresetFactory.create(presetspec);
-
- assertEquals(0.5,preset.get(ComponentPreset.THICKNESS).doubleValue(),0.0);
+
+ assertEquals(0.5, preset.get(ComponentPreset.THICKNESS).doubleValue(), 0.0);
}
-
+
@Test
public void testComputeThicknessLooses() throws Exception {
// If all OUTER_DIAMETER, INNER_DIAMETER and THICKNESS are
// specified, THICKNESS is recomputed.
TypedPropertyMap presetspec = new TypedPropertyMap();
presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.BODY_TUBE);
- presetspec.put( ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
- presetspec.put( ComponentPreset.PARTNO, "partno");
- presetspec.put( ComponentPreset.LENGTH, 2.0);
- presetspec.put( ComponentPreset.OUTER_DIAMETER, 2.0);
- presetspec.put( ComponentPreset.INNER_DIAMETER, 1.0);
- presetspec.put( ComponentPreset.THICKNESS, 15.0);
+ presetspec.put(ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
+ presetspec.put(ComponentPreset.PARTNO, "partno");
+ presetspec.put(ComponentPreset.LENGTH, 2.0);
+ presetspec.put(ComponentPreset.OUTER_DIAMETER, 2.0);
+ presetspec.put(ComponentPreset.INNER_DIAMETER, 1.0);
+ presetspec.put(ComponentPreset.THICKNESS, 15.0);
ComponentPreset preset = ComponentPresetFactory.create(presetspec);
-
- assertEquals(0.5,preset.get(ComponentPreset.THICKNESS).doubleValue(),0.0);
+
+ assertEquals(0.5, preset.get(ComponentPreset.THICKNESS).doubleValue(), 0.0);
}
-
+
@Test
public void testComputeDensityNoMaterial() throws Exception {
TypedPropertyMap presetspec = new TypedPropertyMap();
presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.BODY_TUBE);
- presetspec.put( ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
- presetspec.put( ComponentPreset.PARTNO, "partno");
- presetspec.put( ComponentPreset.LENGTH, 2.0);
- presetspec.put( ComponentPreset.OUTER_DIAMETER, 2.0);
- presetspec.put( ComponentPreset.INNER_DIAMETER, 1.0);
- presetspec.put( ComponentPreset.MASS, 100.0);
+ presetspec.put(ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
+ presetspec.put(ComponentPreset.PARTNO, "partno");
+ presetspec.put(ComponentPreset.LENGTH, 2.0);
+ presetspec.put(ComponentPreset.OUTER_DIAMETER, 2.0);
+ presetspec.put(ComponentPreset.INNER_DIAMETER, 1.0);
+ presetspec.put(ComponentPreset.MASS, 100.0);
ComponentPreset preset = ComponentPresetFactory.create(presetspec);
-
+
// Compute the volume by hand here using a slightly different formula from
// the real implementation. The magic numbers are based on the
// constants put into the presetspec above.
- double volume = /*outer area*/ (Math.PI * 1.0) - /* inner area */ (Math.PI * .25);
+ double volume = /*outer area*/(Math.PI * 1.0) - /* inner area */(Math.PI * .25);
volume *= 2.0; /* times length */
-
+
double density = 100.0 / volume;
-
- assertEquals("TubeCustom",preset.get(ComponentPreset.MATERIAL).getName());
- assertEquals(density,preset.get(ComponentPreset.MATERIAL).getDensity(),0.0005);
+
+ assertEquals("TubeCustom", preset.get(ComponentPreset.MATERIAL).getName());
+ assertEquals(density, preset.get(ComponentPreset.MATERIAL).getDensity(), 0.0005);
}
-
+
@Test
public void testMaterial() throws Exception {
TypedPropertyMap presetspec = new TypedPropertyMap();
presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.BODY_TUBE);
- presetspec.put( ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
- presetspec.put( ComponentPreset.PARTNO, "partno");
- presetspec.put( ComponentPreset.LENGTH, 2.0);
- presetspec.put( ComponentPreset.OUTER_DIAMETER, 2.0);
- presetspec.put( ComponentPreset.INNER_DIAMETER, 1.0);
- presetspec.put( ComponentPreset.MATERIAL, Material.newUserMaterial(Material.Type.BULK,"test", 2.0));
+ presetspec.put(ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
+ presetspec.put(ComponentPreset.PARTNO, "partno");
+ presetspec.put(ComponentPreset.LENGTH, 2.0);
+ presetspec.put(ComponentPreset.OUTER_DIAMETER, 2.0);
+ presetspec.put(ComponentPreset.INNER_DIAMETER, 1.0);
+ presetspec.put(ComponentPreset.MATERIAL, Material.newMaterial(Material.Type.BULK, "test", 2.0, true));
ComponentPreset preset = ComponentPresetFactory.create(presetspec);
-
- assertEquals("test",preset.get(ComponentPreset.MATERIAL).getName());
- assertEquals(2.0,preset.get(ComponentPreset.MATERIAL).getDensity(),0.0005);
-
+
+ assertEquals("test", preset.get(ComponentPreset.MATERIAL).getName());
+ assertEquals(2.0, preset.get(ComponentPreset.MATERIAL).getDensity(), 0.0005);
+
}
-
+
@Test
public void testComputeDensityWithMaterial() throws Exception {
TypedPropertyMap presetspec = new TypedPropertyMap();
presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.BODY_TUBE);
- presetspec.put( ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
- presetspec.put( ComponentPreset.PARTNO, "partno");
- presetspec.put( ComponentPreset.LENGTH, 2.0);
- presetspec.put( ComponentPreset.OUTER_DIAMETER, 2.0);
- presetspec.put( ComponentPreset.INNER_DIAMETER, 1.0);
- presetspec.put( ComponentPreset.MASS, 100.0);
- presetspec.put( ComponentPreset.MATERIAL, Material.newUserMaterial(Material.Type.BULK,"test", 2.0));
+ presetspec.put(ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
+ presetspec.put(ComponentPreset.PARTNO, "partno");
+ presetspec.put(ComponentPreset.LENGTH, 2.0);
+ presetspec.put(ComponentPreset.OUTER_DIAMETER, 2.0);
+ presetspec.put(ComponentPreset.INNER_DIAMETER, 1.0);
+ presetspec.put(ComponentPreset.MASS, 100.0);
+ presetspec.put(ComponentPreset.MATERIAL, Material.newMaterial(Material.Type.BULK, "test", 2.0, true));
ComponentPreset preset = ComponentPresetFactory.create(presetspec);
-
+
// Compute the volume by hand here using a slightly different formula from
// the real implementation. The magic numbers are based on the
// constants put into the presetspec above.
- double volume = /*outer area*/ (Math.PI * 1.0) - /* inner area */ (Math.PI * .25);
+ double volume = /*outer area*/(Math.PI * 1.0) - /* inner area */(Math.PI * .25);
volume *= 2.0; /* times length */
-
+
double density = 100.0 / volume;
-
- assertEquals("test",preset.get(ComponentPreset.MATERIAL).getName());
- assertEquals(density,preset.get(ComponentPreset.MATERIAL).getDensity(),0.0005);
+
+ assertEquals("test", preset.get(ComponentPreset.MATERIAL).getName());
+ assertEquals(density, preset.get(ComponentPreset.MATERIAL).getDensity(), 0.0005);
}
-
+
}
package net.sf.openrocket.preset;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertSame;
+import static org.junit.Assert.*;
import net.sf.openrocket.material.Material;
import net.sf.openrocket.motor.Manufacturer;
import net.sf.openrocket.rocketcomponent.Bulkhead;
*
*/
public class BulkHeadComponentTests extends BaseTestCase {
-
+
ComponentPreset preset;
@Before
public void createPreset() throws Exception {
TypedPropertyMap presetspec = new TypedPropertyMap();
presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.BULK_HEAD);
- presetspec.put( ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
- presetspec.put( ComponentPreset.PARTNO, "partno");
- presetspec.put( ComponentPreset.LENGTH, 2.0);
- presetspec.put( ComponentPreset.OUTER_DIAMETER, 2.0);
- presetspec.put( ComponentPreset.MASS, 100.0);
+ presetspec.put(ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
+ presetspec.put(ComponentPreset.PARTNO, "partno");
+ presetspec.put(ComponentPreset.LENGTH, 2.0);
+ presetspec.put(ComponentPreset.OUTER_DIAMETER, 2.0);
+ presetspec.put(ComponentPreset.MASS, 100.0);
preset = ComponentPresetFactory.create(presetspec);
}
-
+
@Test
public void testComponentType() {
Bulkhead bt = new Bulkhead();
- assertSame( ComponentPreset.Type.BULK_HEAD, bt.getPresetType() );
+ assertSame(ComponentPreset.Type.BULK_HEAD, bt.getPresetType());
}
@Test
bt.loadPreset(preset);
- assertEquals( 2.0, bt.getLength(), 0.0 );
- assertEquals( 1.0, bt.getOuterRadius(), 0.0 );
+ assertEquals(2.0, bt.getLength(), 0.0);
+ assertEquals(1.0, bt.getOuterRadius(), 0.0);
- assertFalse( bt.isOuterRadiusAutomatic() );
+ assertFalse(bt.isOuterRadiusAutomatic());
- assertSame( preset.get( ComponentPreset.MATERIAL), bt.getMaterial() );
- assertEquals( 100.0, bt.getMass(), 0.05);
+ assertSame(preset.get(ComponentPreset.MATERIAL), bt.getMaterial());
+ assertEquals(100.0, bt.getMass(), 0.05);
}
@Test
Bulkhead bt = new Bulkhead();
bt.loadPreset(preset);
-
+
bt.setLength(1.0);
- assertSame( preset, bt.getPresetComponent() );
+ assertSame(preset, bt.getPresetComponent());
}
-
+
@Test
public void changeODClearsPreset() {
Bulkhead bt = new Bulkhead();
bt.loadPreset(preset);
-
+
bt.setOuterRadius(2.0);
- assertNull( bt.getPresetComponent() );
+ assertNull(bt.getPresetComponent());
}
-
+
@Test
public void changeODAutomaticClearsPreset() {
Bulkhead bt = new Bulkhead();
bt.loadPreset(preset);
bt.setOuterRadiusAutomatic(true);
-
- assertNull( bt.getPresetComponent() );
+
+ assertNull(bt.getPresetComponent());
}
-
+
@Test
public void changeMaterialClearsPreset() {
Bulkhead bt = new Bulkhead();
bt.loadPreset(preset);
-
- bt.setMaterial( Material.newUserMaterial(Material.Type.BULK,"new", 1.0));
- assertNull( bt.getPresetComponent() );
+ bt.setMaterial(Material.newMaterial(Material.Type.BULK, "new", 1.0, true));
+
+ assertNull(bt.getPresetComponent());
}
-
+
}
*
*/
public class BulkHeadPresetTests {
-
+
@Test
public void testManufacturerRequired() {
try {
TypedPropertyMap presetspec = new TypedPropertyMap();
presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.BULK_HEAD);
ComponentPresetFactory.create(presetspec);
- } catch ( InvalidComponentPresetException ex ) {
- PresetAssertHelper.assertInvalidPresetException( ex,
+ } catch (InvalidComponentPresetException ex) {
+ PresetAssertHelper.assertInvalidPresetException(ex,
new TypedKey<?>[] {
- ComponentPreset.MANUFACTURER,
- ComponentPreset.PARTNO,
- ComponentPreset.LENGTH,
- ComponentPreset.OUTER_DIAMETER
- },
- new String[] {
- "No Manufacturer specified",
- "No PartNo specified",
- "No Length specified",
- "No OuterDiameter specified"
- }
+ ComponentPreset.MANUFACTURER,
+ ComponentPreset.PARTNO,
+ ComponentPreset.LENGTH,
+ ComponentPreset.OUTER_DIAMETER
+ },
+ new String[] {
+ "No Manufacturer specified",
+ "No PartNo specified",
+ "No Length specified",
+ "No OuterDiameter specified"
+ }
);
}
}
-
+
@Test
public void testPartNoRequired() {
try {
TypedPropertyMap presetspec = new TypedPropertyMap();
presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.BULK_HEAD);
- presetspec.put( ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
+ presetspec.put(ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
ComponentPresetFactory.create(presetspec);
- } catch ( InvalidComponentPresetException ex ) {
- PresetAssertHelper.assertInvalidPresetException( ex,
+ } catch (InvalidComponentPresetException ex) {
+ PresetAssertHelper.assertInvalidPresetException(ex,
new TypedKey<?>[] {
- ComponentPreset.PARTNO,
- ComponentPreset.LENGTH,
- ComponentPreset.OUTER_DIAMETER
- },
- new String[] {
- "No PartNo specified",
- "No Length specified",
- "No OuterDiameter specified"
- }
+ ComponentPreset.PARTNO,
+ ComponentPreset.LENGTH,
+ ComponentPreset.OUTER_DIAMETER
+ },
+ new String[] {
+ "No PartNo specified",
+ "No Length specified",
+ "No OuterDiameter specified"
+ }
);
}
}
-
+
@Test
public void testLengthRequired() {
try {
TypedPropertyMap presetspec = new TypedPropertyMap();
presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.BULK_HEAD);
- presetspec.put( ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
- presetspec.put( ComponentPreset.PARTNO, "partno");
+ presetspec.put(ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
+ presetspec.put(ComponentPreset.PARTNO, "partno");
ComponentPresetFactory.create(presetspec);
- } catch ( InvalidComponentPresetException ex ) {
- PresetAssertHelper.assertInvalidPresetException( ex,
+ } catch (InvalidComponentPresetException ex) {
+ PresetAssertHelper.assertInvalidPresetException(ex,
new TypedKey<?>[] {
- ComponentPreset.LENGTH,
- ComponentPreset.OUTER_DIAMETER
- },
- new String[] {
- "No Length specified",
- "No OuterDiameter specified"
- }
+ ComponentPreset.LENGTH,
+ ComponentPreset.OUTER_DIAMETER
+ },
+ new String[] {
+ "No Length specified",
+ "No OuterDiameter specified"
+ }
);
}
}
-
+
@Test
public void testOuterDiameterRequired() {
try {
TypedPropertyMap presetspec = new TypedPropertyMap();
presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.BULK_HEAD);
- presetspec.put( ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
- presetspec.put( ComponentPreset.PARTNO, "partno");
- presetspec.put( ComponentPreset.LENGTH, 2.0);
+ presetspec.put(ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
+ presetspec.put(ComponentPreset.PARTNO, "partno");
+ presetspec.put(ComponentPreset.LENGTH, 2.0);
ComponentPresetFactory.create(presetspec);
- } catch ( InvalidComponentPresetException ex ) {
- PresetAssertHelper.assertInvalidPresetException( ex,
+ } catch (InvalidComponentPresetException ex) {
+ PresetAssertHelper.assertInvalidPresetException(ex,
new TypedKey<?>[] {
ComponentPreset.OUTER_DIAMETER
- },
- new String[] {
+ },
+ new String[] {
"No OuterDiameter specified"
- }
+ }
);
}
}
-
+
@Test
public void testComputeDensityNoMaterial() throws Exception {
TypedPropertyMap presetspec = new TypedPropertyMap();
presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.BULK_HEAD);
- presetspec.put( ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
- presetspec.put( ComponentPreset.PARTNO, "partno");
- presetspec.put( ComponentPreset.LENGTH, 2.0);
- presetspec.put( ComponentPreset.OUTER_DIAMETER, 2.0);
- presetspec.put( ComponentPreset.MASS, 100.0);
+ presetspec.put(ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
+ presetspec.put(ComponentPreset.PARTNO, "partno");
+ presetspec.put(ComponentPreset.LENGTH, 2.0);
+ presetspec.put(ComponentPreset.OUTER_DIAMETER, 2.0);
+ presetspec.put(ComponentPreset.MASS, 100.0);
ComponentPreset preset = ComponentPresetFactory.create(presetspec);
-
+
// Compute the volume by hand here using a slightly different formula from
// the real implementation. The magic numbers are based on the
// constants put into the presetspec above.
- double volume = /*outer area*/ (Math.PI * 1.0);
+ double volume = /*outer area*/(Math.PI * 1.0);
volume *= 2.0; /* times length */
double density = 100.0 / volume;
- assertEquals("BulkHeadCustom",preset.get(ComponentPreset.MATERIAL).getName());
- assertEquals(density,preset.get(ComponentPreset.MATERIAL).getDensity(),0.0005);
+ assertEquals("BulkHeadCustom", preset.get(ComponentPreset.MATERIAL).getName());
+ assertEquals(density, preset.get(ComponentPreset.MATERIAL).getDensity(), 0.0005);
}
-
+
@Test
public void testMaterial() throws Exception {
TypedPropertyMap presetspec = new TypedPropertyMap();
presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.BULK_HEAD);
- presetspec.put( ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
- presetspec.put( ComponentPreset.PARTNO, "partno");
- presetspec.put( ComponentPreset.LENGTH, 2.0);
- presetspec.put( ComponentPreset.OUTER_DIAMETER, 2.0);
- presetspec.put( ComponentPreset.MATERIAL, Material.newUserMaterial(Material.Type.BULK,"test", 2.0));
+ presetspec.put(ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
+ presetspec.put(ComponentPreset.PARTNO, "partno");
+ presetspec.put(ComponentPreset.LENGTH, 2.0);
+ presetspec.put(ComponentPreset.OUTER_DIAMETER, 2.0);
+ presetspec.put(ComponentPreset.MATERIAL, Material.newMaterial(Material.Type.BULK, "test", 2.0, true));
ComponentPreset preset = ComponentPresetFactory.create(presetspec);
-
- assertEquals("test",preset.get(ComponentPreset.MATERIAL).getName());
- assertEquals(2.0,preset.get(ComponentPreset.MATERIAL).getDensity(),0.0005);
+
+ assertEquals("test", preset.get(ComponentPreset.MATERIAL).getName());
+ assertEquals(2.0, preset.get(ComponentPreset.MATERIAL).getDensity(), 0.0005);
}
-
+
@Test
public void testComputeDensityWithMaterial() throws Exception {
TypedPropertyMap presetspec = new TypedPropertyMap();
presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.BULK_HEAD);
- presetspec.put( ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
- presetspec.put( ComponentPreset.PARTNO, "partno");
- presetspec.put( ComponentPreset.LENGTH, 2.0);
- presetspec.put( ComponentPreset.OUTER_DIAMETER, 2.0);
- presetspec.put( ComponentPreset.MASS, 100.0);
- presetspec.put( ComponentPreset.MATERIAL, Material.newUserMaterial(Material.Type.BULK,"test", 2.0));
+ presetspec.put(ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
+ presetspec.put(ComponentPreset.PARTNO, "partno");
+ presetspec.put(ComponentPreset.LENGTH, 2.0);
+ presetspec.put(ComponentPreset.OUTER_DIAMETER, 2.0);
+ presetspec.put(ComponentPreset.MASS, 100.0);
+ presetspec.put(ComponentPreset.MATERIAL, Material.newMaterial(Material.Type.BULK, "test", 2.0, true));
ComponentPreset preset = ComponentPresetFactory.create(presetspec);
-
+
// Compute the volume by hand here using a slightly different formula from
// the real implementation. The magic numbers are based on the
// constants put into the presetspec above.
- double volume = /*outer area*/ (Math.PI * 1.0);
+ double volume = /*outer area*/(Math.PI * 1.0);
volume *= 2.0; /* times length */
double density = 100.0 / volume;
- assertEquals("test",preset.get(ComponentPreset.MATERIAL).getName());
- assertEquals(density,preset.get(ComponentPreset.MATERIAL).getDensity(),0.0005);
+ assertEquals("test", preset.get(ComponentPreset.MATERIAL).getName());
+ assertEquals(density, preset.get(ComponentPreset.MATERIAL).getDensity(), 0.0005);
}
-
+
}
package net.sf.openrocket.preset;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertSame;
+import static org.junit.Assert.*;
import net.sf.openrocket.material.Material;
import net.sf.openrocket.motor.Manufacturer;
import net.sf.openrocket.rocketcomponent.CenteringRing;
*
*/
public class CenteringRingComponentTests extends BaseTestCase {
-
+
ComponentPreset preset;
@Before
public void createPreset() throws Exception {
TypedPropertyMap presetspec = new TypedPropertyMap();
presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.CENTERING_RING);
- presetspec.put( ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
- presetspec.put( ComponentPreset.PARTNO, "partno");
- presetspec.put( ComponentPreset.LENGTH, 2.0);
- presetspec.put( ComponentPreset.OUTER_DIAMETER, 2.0);
- presetspec.put( ComponentPreset.INNER_DIAMETER, 1.0);
- presetspec.put( ComponentPreset.MASS, 100.0);
+ presetspec.put(ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
+ presetspec.put(ComponentPreset.PARTNO, "partno");
+ presetspec.put(ComponentPreset.LENGTH, 2.0);
+ presetspec.put(ComponentPreset.OUTER_DIAMETER, 2.0);
+ presetspec.put(ComponentPreset.INNER_DIAMETER, 1.0);
+ presetspec.put(ComponentPreset.MASS, 100.0);
preset = ComponentPresetFactory.create(presetspec);
}
-
+
@Test
public void testComponentType() {
CenteringRing cr = new CenteringRing();
- assertSame( ComponentPreset.Type.CENTERING_RING, cr.getPresetType() );
+ assertSame(ComponentPreset.Type.CENTERING_RING, cr.getPresetType());
}
@Test
cr.loadPreset(preset);
- assertEquals( 2.0, cr.getLength(), 0.0 );
- assertEquals( 1.0, cr.getOuterRadius(), 0.0 );
- assertEquals( 0.5, cr.getInnerRadius(), 0.0 );
+ assertEquals(2.0, cr.getLength(), 0.0);
+ assertEquals(1.0, cr.getOuterRadius(), 0.0);
+ assertEquals(0.5, cr.getInnerRadius(), 0.0);
- assertFalse( cr.isOuterRadiusAutomatic() );
+ assertFalse(cr.isOuterRadiusAutomatic());
- assertSame( preset.get( ComponentPreset.MATERIAL), cr.getMaterial() );
- assertEquals( 100.0, cr.getMass(), 0.05);
+ assertSame(preset.get(ComponentPreset.MATERIAL), cr.getMaterial());
+ assertEquals(100.0, cr.getMass(), 0.05);
}
@Test
CenteringRing cr = new CenteringRing();
cr.loadPreset(preset);
-
+
cr.setLength(1.0);
- assertSame( preset, cr.getPresetComponent() );
+ assertSame(preset, cr.getPresetComponent());
}
-
+
@Test
public void changeODClearsPreset() {
CenteringRing cr = new CenteringRing();
cr.loadPreset(preset);
-
+
cr.setOuterRadius(2.0);
- assertNull( cr.getPresetComponent() );
+ assertNull(cr.getPresetComponent());
}
-
+
@Test
public void changeIDClearsPreset() {
CenteringRing cr = new CenteringRing();
cr.loadPreset(preset);
-
+
cr.setInnerRadius(0.75);
- assertNull( cr.getPresetComponent() );
+ assertNull(cr.getPresetComponent());
}
-
+
@Test
public void changeThicknessClearsPreset() {
CenteringRing cr = new CenteringRing();
cr.loadPreset(preset);
-
+
cr.setThickness(0.1);
- assertNull( cr.getPresetComponent() );
+ assertNull(cr.getPresetComponent());
}
-
+
@Test
public void changeMaterialClearsPreset() {
CenteringRing cr = new CenteringRing();
cr.loadPreset(preset);
-
- cr.setMaterial( Material.newUserMaterial(Material.Type.BULK,"new", 1.0));
- assertNull( cr.getPresetComponent() );
+ cr.setMaterial(Material.newMaterial(Material.Type.BULK, "new", 1.0, true));
+
+ assertNull(cr.getPresetComponent());
}
-
+
}
*
*/
public class CenteringRingPresetTests {
-
+
@Test
public void testManufacturerRequired() {
try {
TypedPropertyMap presetspec = new TypedPropertyMap();
presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.CENTERING_RING);
ComponentPresetFactory.create(presetspec);
- } catch ( InvalidComponentPresetException ex ) {
- PresetAssertHelper.assertInvalidPresetException( ex,
+ } catch (InvalidComponentPresetException ex) {
+ PresetAssertHelper.assertInvalidPresetException(ex,
new TypedKey<?>[] {
- ComponentPreset.MANUFACTURER,
- ComponentPreset.PARTNO,
- ComponentPreset.LENGTH
- },
- new String[] {
- "No Manufacturer specified",
- "No PartNo specified",
- "No Length specified",
- "Preset dimensions underspecified"
- }
+ ComponentPreset.MANUFACTURER,
+ ComponentPreset.PARTNO,
+ ComponentPreset.LENGTH
+ },
+ new String[] {
+ "No Manufacturer specified",
+ "No PartNo specified",
+ "No Length specified",
+ "Preset dimensions underspecified"
+ }
);
}
}
-
+
@Test
public void testPartNoRequired() {
try {
TypedPropertyMap presetspec = new TypedPropertyMap();
presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.CENTERING_RING);
- presetspec.put( ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
+ presetspec.put(ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
ComponentPresetFactory.create(presetspec);
- } catch ( InvalidComponentPresetException ex ) {
- PresetAssertHelper.assertInvalidPresetException( ex,
+ } catch (InvalidComponentPresetException ex) {
+ PresetAssertHelper.assertInvalidPresetException(ex,
new TypedKey<?>[] {
- ComponentPreset.PARTNO,
- ComponentPreset.LENGTH
- },
- new String[] {
- "No PartNo specified",
- "No Length specified",
- "Preset dimensions underspecified"
- }
+ ComponentPreset.PARTNO,
+ ComponentPreset.LENGTH
+ },
+ new String[] {
+ "No PartNo specified",
+ "No Length specified",
+ "Preset dimensions underspecified"
+ }
);
}
}
-
+
@Test
public void testLengthRequired() {
try {
TypedPropertyMap presetspec = new TypedPropertyMap();
presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.CENTERING_RING);
- presetspec.put( ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
- presetspec.put( ComponentPreset.PARTNO, "partno");
+ presetspec.put(ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
+ presetspec.put(ComponentPreset.PARTNO, "partno");
ComponentPresetFactory.create(presetspec);
- } catch ( InvalidComponentPresetException ex ) {
- PresetAssertHelper.assertInvalidPresetException( ex,
+ } catch (InvalidComponentPresetException ex) {
+ PresetAssertHelper.assertInvalidPresetException(ex,
new TypedKey<?>[] {
ComponentPreset.LENGTH
- },
- new String[] {
- "No Length specified",
- "Preset dimensions underspecified"
- }
+ },
+ new String[] {
+ "No Length specified",
+ "Preset dimensions underspecified"
+ }
);
}
}
-
+
@Test
public void testOnlyOuterDiameter() {
try {
TypedPropertyMap presetspec = new TypedPropertyMap();
presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.CENTERING_RING);
- presetspec.put( ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
- presetspec.put( ComponentPreset.PARTNO, "partno");
- presetspec.put( ComponentPreset.LENGTH, 2.0);
- presetspec.put( ComponentPreset.OUTER_DIAMETER, 2.0);
+ presetspec.put(ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
+ presetspec.put(ComponentPreset.PARTNO, "partno");
+ presetspec.put(ComponentPreset.LENGTH, 2.0);
+ presetspec.put(ComponentPreset.OUTER_DIAMETER, 2.0);
ComponentPresetFactory.create(presetspec);
- } catch ( InvalidComponentPresetException ex ) {
- PresetAssertHelper.assertInvalidPresetException( ex,
+ } catch (InvalidComponentPresetException ex) {
+ PresetAssertHelper.assertInvalidPresetException(ex,
null,
- new String[] {
+ new String[] {
"Preset dimensions underspecified"
- }
+ }
);
}
}
-
+
@Test
public void testOnlyInnerDiameter() {
try {
TypedPropertyMap presetspec = new TypedPropertyMap();
presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.CENTERING_RING);
- presetspec.put( ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
- presetspec.put( ComponentPreset.PARTNO, "partno");
- presetspec.put( ComponentPreset.LENGTH, 2.0);
- presetspec.put( ComponentPreset.INNER_DIAMETER, 2.0);
+ presetspec.put(ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
+ presetspec.put(ComponentPreset.PARTNO, "partno");
+ presetspec.put(ComponentPreset.LENGTH, 2.0);
+ presetspec.put(ComponentPreset.INNER_DIAMETER, 2.0);
ComponentPresetFactory.create(presetspec);
- } catch ( InvalidComponentPresetException ex ) {
- PresetAssertHelper.assertInvalidPresetException( ex,
+ } catch (InvalidComponentPresetException ex) {
+ PresetAssertHelper.assertInvalidPresetException(ex,
null,
- new String[] {
+ new String[] {
"Preset dimensions underspecified"
- }
+ }
);
}
}
-
+
@Test
public void testOnlyThicknessDiameter() {
try {
TypedPropertyMap presetspec = new TypedPropertyMap();
presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.CENTERING_RING);
- presetspec.put( ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
- presetspec.put( ComponentPreset.PARTNO, "partno");
- presetspec.put( ComponentPreset.LENGTH, 2.0);
- presetspec.put( ComponentPreset.THICKNESS, 2.0);
+ presetspec.put(ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
+ presetspec.put(ComponentPreset.PARTNO, "partno");
+ presetspec.put(ComponentPreset.LENGTH, 2.0);
+ presetspec.put(ComponentPreset.THICKNESS, 2.0);
ComponentPresetFactory.create(presetspec);
- } catch ( InvalidComponentPresetException ex ) {
- PresetAssertHelper.assertInvalidPresetException( ex,
+ } catch (InvalidComponentPresetException ex) {
+ PresetAssertHelper.assertInvalidPresetException(ex,
null,
- new String[] {
+ new String[] {
"Preset dimensions underspecified"
- }
+ }
);
}
}
-
+
@Test
public void testComputeInnerDiameter() throws Exception {
TypedPropertyMap presetspec = new TypedPropertyMap();
presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.CENTERING_RING);
- presetspec.put( ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
- presetspec.put( ComponentPreset.PARTNO, "partno");
- presetspec.put( ComponentPreset.LENGTH, 2.0);
- presetspec.put( ComponentPreset.OUTER_DIAMETER, 2.0);
- presetspec.put( ComponentPreset.THICKNESS, 0.5);
+ presetspec.put(ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
+ presetspec.put(ComponentPreset.PARTNO, "partno");
+ presetspec.put(ComponentPreset.LENGTH, 2.0);
+ presetspec.put(ComponentPreset.OUTER_DIAMETER, 2.0);
+ presetspec.put(ComponentPreset.THICKNESS, 0.5);
ComponentPreset preset = ComponentPresetFactory.create(presetspec);
-
- assertEquals(1.0,preset.get(ComponentPreset.INNER_DIAMETER).doubleValue(),0.0);
+
+ assertEquals(1.0, preset.get(ComponentPreset.INNER_DIAMETER).doubleValue(), 0.0);
}
-
+
@Test
public void testComputeOuterDiameter() throws Exception {
TypedPropertyMap presetspec = new TypedPropertyMap();
presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.CENTERING_RING);
- presetspec.put( ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
- presetspec.put( ComponentPreset.PARTNO, "partno");
- presetspec.put( ComponentPreset.LENGTH, 2.0);
- presetspec.put( ComponentPreset.INNER_DIAMETER, 1.0);
- presetspec.put( ComponentPreset.THICKNESS, 0.5);
+ presetspec.put(ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
+ presetspec.put(ComponentPreset.PARTNO, "partno");
+ presetspec.put(ComponentPreset.LENGTH, 2.0);
+ presetspec.put(ComponentPreset.INNER_DIAMETER, 1.0);
+ presetspec.put(ComponentPreset.THICKNESS, 0.5);
ComponentPreset preset = ComponentPresetFactory.create(presetspec);
-
- assertEquals(2.0,preset.get(ComponentPreset.OUTER_DIAMETER).doubleValue(),0.0);
+
+ assertEquals(2.0, preset.get(ComponentPreset.OUTER_DIAMETER).doubleValue(), 0.0);
}
-
+
@Test
public void testComputeThickness() throws Exception {
TypedPropertyMap presetspec = new TypedPropertyMap();
presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.CENTERING_RING);
- presetspec.put( ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
- presetspec.put( ComponentPreset.PARTNO, "partno");
- presetspec.put( ComponentPreset.LENGTH, 2.0);
- presetspec.put( ComponentPreset.OUTER_DIAMETER, 2.0);
- presetspec.put( ComponentPreset.INNER_DIAMETER, 1.0);
+ presetspec.put(ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
+ presetspec.put(ComponentPreset.PARTNO, "partno");
+ presetspec.put(ComponentPreset.LENGTH, 2.0);
+ presetspec.put(ComponentPreset.OUTER_DIAMETER, 2.0);
+ presetspec.put(ComponentPreset.INNER_DIAMETER, 1.0);
ComponentPreset preset = ComponentPresetFactory.create(presetspec);
-
- assertEquals(0.5,preset.get(ComponentPreset.THICKNESS).doubleValue(),0.0);
+
+ assertEquals(0.5, preset.get(ComponentPreset.THICKNESS).doubleValue(), 0.0);
}
-
+
@Test
public void testComputeThicknessLooses() throws Exception {
// If all OUTER_DIAMETER, INNER_DIAMETER and THICKNESS are
// specified, THICKNESS is recomputed.
TypedPropertyMap presetspec = new TypedPropertyMap();
presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.CENTERING_RING);
- presetspec.put( ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
- presetspec.put( ComponentPreset.PARTNO, "partno");
- presetspec.put( ComponentPreset.LENGTH, 2.0);
- presetspec.put( ComponentPreset.OUTER_DIAMETER, 2.0);
- presetspec.put( ComponentPreset.INNER_DIAMETER, 1.0);
- presetspec.put( ComponentPreset.THICKNESS, 15.0);
+ presetspec.put(ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
+ presetspec.put(ComponentPreset.PARTNO, "partno");
+ presetspec.put(ComponentPreset.LENGTH, 2.0);
+ presetspec.put(ComponentPreset.OUTER_DIAMETER, 2.0);
+ presetspec.put(ComponentPreset.INNER_DIAMETER, 1.0);
+ presetspec.put(ComponentPreset.THICKNESS, 15.0);
ComponentPreset preset = ComponentPresetFactory.create(presetspec);
-
- assertEquals(0.5,preset.get(ComponentPreset.THICKNESS).doubleValue(),0.0);
+
+ assertEquals(0.5, preset.get(ComponentPreset.THICKNESS).doubleValue(), 0.0);
}
-
+
@Test
public void testComputeDensityNoMaterial() throws Exception {
TypedPropertyMap presetspec = new TypedPropertyMap();
presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.CENTERING_RING);
- presetspec.put( ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
- presetspec.put( ComponentPreset.PARTNO, "partno");
- presetspec.put( ComponentPreset.LENGTH, 2.0);
- presetspec.put( ComponentPreset.OUTER_DIAMETER, 2.0);
- presetspec.put( ComponentPreset.INNER_DIAMETER, 1.0);
- presetspec.put( ComponentPreset.MASS, 100.0);
+ presetspec.put(ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
+ presetspec.put(ComponentPreset.PARTNO, "partno");
+ presetspec.put(ComponentPreset.LENGTH, 2.0);
+ presetspec.put(ComponentPreset.OUTER_DIAMETER, 2.0);
+ presetspec.put(ComponentPreset.INNER_DIAMETER, 1.0);
+ presetspec.put(ComponentPreset.MASS, 100.0);
ComponentPreset preset = ComponentPresetFactory.create(presetspec);
-
+
// Compute the volume by hand here using a slightly different formula from
// the real implementation. The magic numbers are based on the
// constants put into the presetspec above.
- double volume = /*outer area*/ (Math.PI * 1.0) - /* inner area */ (Math.PI * .25);
+ double volume = /*outer area*/(Math.PI * 1.0) - /* inner area */(Math.PI * .25);
volume *= 2.0; /* times length */
-
+
double density = 100.0 / volume;
-
- assertEquals("CenteringRingCustom",preset.get(ComponentPreset.MATERIAL).getName());
- assertEquals(density,preset.get(ComponentPreset.MATERIAL).getDensity(),0.0005);
+
+ assertEquals("CenteringRingCustom", preset.get(ComponentPreset.MATERIAL).getName());
+ assertEquals(density, preset.get(ComponentPreset.MATERIAL).getDensity(), 0.0005);
}
-
+
@Test
public void testMaterial() throws Exception {
TypedPropertyMap presetspec = new TypedPropertyMap();
presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.CENTERING_RING);
- presetspec.put( ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
- presetspec.put( ComponentPreset.PARTNO, "partno");
- presetspec.put( ComponentPreset.LENGTH, 2.0);
- presetspec.put( ComponentPreset.OUTER_DIAMETER, 2.0);
- presetspec.put( ComponentPreset.INNER_DIAMETER, 1.0);
- presetspec.put( ComponentPreset.MATERIAL, Material.newUserMaterial(Material.Type.BULK,"test", 2.0));
+ presetspec.put(ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
+ presetspec.put(ComponentPreset.PARTNO, "partno");
+ presetspec.put(ComponentPreset.LENGTH, 2.0);
+ presetspec.put(ComponentPreset.OUTER_DIAMETER, 2.0);
+ presetspec.put(ComponentPreset.INNER_DIAMETER, 1.0);
+ presetspec.put(ComponentPreset.MATERIAL, Material.newMaterial(Material.Type.BULK, "test", 2.0, true));
ComponentPreset preset = ComponentPresetFactory.create(presetspec);
-
- assertEquals("test",preset.get(ComponentPreset.MATERIAL).getName());
- assertEquals(2.0,preset.get(ComponentPreset.MATERIAL).getDensity(),0.0005);
-
+
+ assertEquals("test", preset.get(ComponentPreset.MATERIAL).getName());
+ assertEquals(2.0, preset.get(ComponentPreset.MATERIAL).getDensity(), 0.0005);
+
}
-
+
@Test
public void testComputeDensityWithMaterial() throws Exception {
TypedPropertyMap presetspec = new TypedPropertyMap();
presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.CENTERING_RING);
- presetspec.put( ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
- presetspec.put( ComponentPreset.PARTNO, "partno");
- presetspec.put( ComponentPreset.LENGTH, 2.0);
- presetspec.put( ComponentPreset.OUTER_DIAMETER, 2.0);
- presetspec.put( ComponentPreset.INNER_DIAMETER, 1.0);
- presetspec.put( ComponentPreset.MASS, 100.0);
- presetspec.put( ComponentPreset.MATERIAL, Material.newUserMaterial(Material.Type.BULK,"test", 2.0));
+ presetspec.put(ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
+ presetspec.put(ComponentPreset.PARTNO, "partno");
+ presetspec.put(ComponentPreset.LENGTH, 2.0);
+ presetspec.put(ComponentPreset.OUTER_DIAMETER, 2.0);
+ presetspec.put(ComponentPreset.INNER_DIAMETER, 1.0);
+ presetspec.put(ComponentPreset.MASS, 100.0);
+ presetspec.put(ComponentPreset.MATERIAL, Material.newMaterial(Material.Type.BULK, "test", 2.0, true));
ComponentPreset preset = ComponentPresetFactory.create(presetspec);
-
+
// Compute the volume by hand here using a slightly different formula from
// the real implementation. The magic numbers are based on the
// constants put into the presetspec above.
- double volume = /*outer area*/ (Math.PI * 1.0) - /* inner area */ (Math.PI * .25);
+ double volume = /*outer area*/(Math.PI * 1.0) - /* inner area */(Math.PI * .25);
volume *= 2.0; /* times length */
-
+
double density = 100.0 / volume;
-
- assertEquals("test",preset.get(ComponentPreset.MATERIAL).getName());
- assertEquals(density,preset.get(ComponentPreset.MATERIAL).getDensity(),0.0005);
+
+ assertEquals("test", preset.get(ComponentPreset.MATERIAL).getName());
+ assertEquals(density, preset.get(ComponentPreset.MATERIAL).getDensity(), 0.0005);
}
-
+
}
package net.sf.openrocket.preset;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertSame;
+import static org.junit.Assert.*;
import net.sf.openrocket.material.Material;
import net.sf.openrocket.motor.Manufacturer;
import net.sf.openrocket.rocketcomponent.EngineBlock;
*
*/
public class EngineBlockComponentTests extends BaseTestCase {
-
+
ComponentPreset preset;
@Before
public void createPreset() throws Exception {
TypedPropertyMap presetspec = new TypedPropertyMap();
presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.ENGINE_BLOCK);
- presetspec.put( ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
- presetspec.put( ComponentPreset.PARTNO, "partno");
- presetspec.put( ComponentPreset.LENGTH, 2.0);
- presetspec.put( ComponentPreset.OUTER_DIAMETER, 2.0);
- presetspec.put( ComponentPreset.INNER_DIAMETER, 1.0);
- presetspec.put( ComponentPreset.MASS, 100.0);
+ presetspec.put(ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
+ presetspec.put(ComponentPreset.PARTNO, "partno");
+ presetspec.put(ComponentPreset.LENGTH, 2.0);
+ presetspec.put(ComponentPreset.OUTER_DIAMETER, 2.0);
+ presetspec.put(ComponentPreset.INNER_DIAMETER, 1.0);
+ presetspec.put(ComponentPreset.MASS, 100.0);
preset = ComponentPresetFactory.create(presetspec);
}
-
+
@Test
public void testComponentType() {
EngineBlock eb = new EngineBlock();
- assertSame( ComponentPreset.Type.ENGINE_BLOCK, eb.getPresetType() );
+ assertSame(ComponentPreset.Type.ENGINE_BLOCK, eb.getPresetType());
}
@Test
eb.loadPreset(preset);
- assertEquals( 2.0, eb.getLength(), 0.0 );
- assertEquals( 1.0, eb.getOuterRadius(), 0.0 );
- assertEquals( 0.5, eb.getInnerRadius(), 0.0 );
+ assertEquals(2.0, eb.getLength(), 0.0);
+ assertEquals(1.0, eb.getOuterRadius(), 0.0);
+ assertEquals(0.5, eb.getInnerRadius(), 0.0);
- assertFalse( eb.isOuterRadiusAutomatic() );
+ assertFalse(eb.isOuterRadiusAutomatic());
- assertSame( preset.get( ComponentPreset.MATERIAL), eb.getMaterial() );
- assertEquals( 100.0, eb.getMass(), 0.05);
+ assertSame(preset.get(ComponentPreset.MATERIAL), eb.getMaterial());
+ assertEquals(100.0, eb.getMass(), 0.05);
}
@Test
EngineBlock eb = new EngineBlock();
eb.loadPreset(preset);
-
+
eb.setLength(1.0);
- assertSame( preset, eb.getPresetComponent() );
+ assertSame(preset, eb.getPresetComponent());
}
-
+
@Test
public void changeODClearsPreset() {
EngineBlock eb = new EngineBlock();
eb.loadPreset(preset);
-
+
eb.setOuterRadius(2.0);
- assertNull( eb.getPresetComponent() );
+ assertNull(eb.getPresetComponent());
}
-
+
@Test
public void changeIDClearsPreset() {
EngineBlock eb = new EngineBlock();
eb.loadPreset(preset);
-
+
eb.setInnerRadius(0.75);
- assertNull( eb.getPresetComponent() );
+ assertNull(eb.getPresetComponent());
}
-
+
@Test
public void changeThicknessClearsPreset() {
EngineBlock eb = new EngineBlock();
eb.loadPreset(preset);
-
+
eb.setThickness(0.1);
- assertNull( eb.getPresetComponent() );
+ assertNull(eb.getPresetComponent());
}
-
+
@Test
public void changeMaterialClearsPreset() {
EngineBlock eb = new EngineBlock();
eb.loadPreset(preset);
-
- eb.setMaterial( Material.newUserMaterial(Material.Type.BULK,"new", 1.0));
- assertNull( eb.getPresetComponent() );
+ eb.setMaterial(Material.newMaterial(Material.Type.BULK, "new", 1.0, true));
+
+ assertNull(eb.getPresetComponent());
}
-
+
}
*
*/
public class EngineBlockPresetTests {
-
+
@Test
public void testManufacturerRequired() {
try {
TypedPropertyMap presetspec = new TypedPropertyMap();
presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.ENGINE_BLOCK);
ComponentPresetFactory.create(presetspec);
- } catch ( InvalidComponentPresetException ex ) {
- PresetAssertHelper.assertInvalidPresetException( ex,
+ } catch (InvalidComponentPresetException ex) {
+ PresetAssertHelper.assertInvalidPresetException(ex,
new TypedKey<?>[] {
- ComponentPreset.MANUFACTURER,
- ComponentPreset.PARTNO,
- ComponentPreset.LENGTH
- },
- new String[] {
- "No Manufacturer specified",
- "No PartNo specified",
- "No Length specified",
- "Preset dimensions underspecified"
- }
+ ComponentPreset.MANUFACTURER,
+ ComponentPreset.PARTNO,
+ ComponentPreset.LENGTH
+ },
+ new String[] {
+ "No Manufacturer specified",
+ "No PartNo specified",
+ "No Length specified",
+ "Preset dimensions underspecified"
+ }
);
}
}
-
+
@Test
public void testPartNoRequired() {
try {
TypedPropertyMap presetspec = new TypedPropertyMap();
presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.ENGINE_BLOCK);
- presetspec.put( ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
+ presetspec.put(ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
ComponentPresetFactory.create(presetspec);
- } catch ( InvalidComponentPresetException ex ) {
- PresetAssertHelper.assertInvalidPresetException( ex,
+ } catch (InvalidComponentPresetException ex) {
+ PresetAssertHelper.assertInvalidPresetException(ex,
new TypedKey<?>[] {
- ComponentPreset.PARTNO,
- ComponentPreset.LENGTH
- },
- new String[] {
- "No PartNo specified",
- "No Length specified",
- "Preset dimensions underspecified"
- }
+ ComponentPreset.PARTNO,
+ ComponentPreset.LENGTH
+ },
+ new String[] {
+ "No PartNo specified",
+ "No Length specified",
+ "Preset dimensions underspecified"
+ }
);
}
}
-
+
@Test
public void testLengthRequired() {
try {
TypedPropertyMap presetspec = new TypedPropertyMap();
presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.ENGINE_BLOCK);
- presetspec.put( ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
- presetspec.put( ComponentPreset.PARTNO, "partno");
+ presetspec.put(ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
+ presetspec.put(ComponentPreset.PARTNO, "partno");
ComponentPresetFactory.create(presetspec);
- } catch ( InvalidComponentPresetException ex ) {
- PresetAssertHelper.assertInvalidPresetException( ex,
+ } catch (InvalidComponentPresetException ex) {
+ PresetAssertHelper.assertInvalidPresetException(ex,
new TypedKey<?>[] {
ComponentPreset.LENGTH
- },
- new String[] {
- "No Length specified",
- "Preset dimensions underspecified"
- }
+ },
+ new String[] {
+ "No Length specified",
+ "Preset dimensions underspecified"
+ }
);
}
}
-
+
@Test
public void testOnlyOuterDiameter() {
try {
TypedPropertyMap presetspec = new TypedPropertyMap();
presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.ENGINE_BLOCK);
- presetspec.put( ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
- presetspec.put( ComponentPreset.PARTNO, "partno");
- presetspec.put( ComponentPreset.LENGTH, 2.0);
- presetspec.put( ComponentPreset.OUTER_DIAMETER, 2.0);
+ presetspec.put(ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
+ presetspec.put(ComponentPreset.PARTNO, "partno");
+ presetspec.put(ComponentPreset.LENGTH, 2.0);
+ presetspec.put(ComponentPreset.OUTER_DIAMETER, 2.0);
ComponentPresetFactory.create(presetspec);
- } catch ( InvalidComponentPresetException ex ) {
- PresetAssertHelper.assertInvalidPresetException( ex,
+ } catch (InvalidComponentPresetException ex) {
+ PresetAssertHelper.assertInvalidPresetException(ex,
null,
- new String[] {
+ new String[] {
"Preset dimensions underspecified"
- }
+ }
);
}
}
-
+
@Test
public void testOnlyInnerDiameter() {
try {
TypedPropertyMap presetspec = new TypedPropertyMap();
presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.ENGINE_BLOCK);
- presetspec.put( ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
- presetspec.put( ComponentPreset.PARTNO, "partno");
- presetspec.put( ComponentPreset.LENGTH, 2.0);
- presetspec.put( ComponentPreset.INNER_DIAMETER, 2.0);
+ presetspec.put(ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
+ presetspec.put(ComponentPreset.PARTNO, "partno");
+ presetspec.put(ComponentPreset.LENGTH, 2.0);
+ presetspec.put(ComponentPreset.INNER_DIAMETER, 2.0);
ComponentPresetFactory.create(presetspec);
- } catch ( InvalidComponentPresetException ex ) {
- PresetAssertHelper.assertInvalidPresetException( ex,
+ } catch (InvalidComponentPresetException ex) {
+ PresetAssertHelper.assertInvalidPresetException(ex,
null,
- new String[] {
+ new String[] {
"Preset dimensions underspecified"
- }
+ }
);
}
}
-
+
@Test
public void testOnlyThicknessDiameter() {
try {
TypedPropertyMap presetspec = new TypedPropertyMap();
presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.ENGINE_BLOCK);
- presetspec.put( ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
- presetspec.put( ComponentPreset.PARTNO, "partno");
- presetspec.put( ComponentPreset.LENGTH, 2.0);
- presetspec.put( ComponentPreset.THICKNESS, 2.0);
+ presetspec.put(ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
+ presetspec.put(ComponentPreset.PARTNO, "partno");
+ presetspec.put(ComponentPreset.LENGTH, 2.0);
+ presetspec.put(ComponentPreset.THICKNESS, 2.0);
ComponentPresetFactory.create(presetspec);
- } catch ( InvalidComponentPresetException ex ) {
- PresetAssertHelper.assertInvalidPresetException( ex,
+ } catch (InvalidComponentPresetException ex) {
+ PresetAssertHelper.assertInvalidPresetException(ex,
null,
- new String[] {
+ new String[] {
"Preset dimensions underspecified"
- }
+ }
);
}
}
-
+
@Test
public void testComputeInnerDiameter() throws Exception {
TypedPropertyMap presetspec = new TypedPropertyMap();
presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.ENGINE_BLOCK);
- presetspec.put( ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
- presetspec.put( ComponentPreset.PARTNO, "partno");
- presetspec.put( ComponentPreset.LENGTH, 2.0);
- presetspec.put( ComponentPreset.OUTER_DIAMETER, 2.0);
- presetspec.put( ComponentPreset.THICKNESS, 0.5);
+ presetspec.put(ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
+ presetspec.put(ComponentPreset.PARTNO, "partno");
+ presetspec.put(ComponentPreset.LENGTH, 2.0);
+ presetspec.put(ComponentPreset.OUTER_DIAMETER, 2.0);
+ presetspec.put(ComponentPreset.THICKNESS, 0.5);
ComponentPreset preset = ComponentPresetFactory.create(presetspec);
-
- assertEquals(1.0,preset.get(ComponentPreset.INNER_DIAMETER).doubleValue(),0.0);
+
+ assertEquals(1.0, preset.get(ComponentPreset.INNER_DIAMETER).doubleValue(), 0.0);
}
-
+
@Test
public void testComputeOuterDiameter() throws Exception {
TypedPropertyMap presetspec = new TypedPropertyMap();
presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.ENGINE_BLOCK);
- presetspec.put( ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
- presetspec.put( ComponentPreset.PARTNO, "partno");
- presetspec.put( ComponentPreset.LENGTH, 2.0);
- presetspec.put( ComponentPreset.INNER_DIAMETER, 1.0);
- presetspec.put( ComponentPreset.THICKNESS, 0.5);
+ presetspec.put(ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
+ presetspec.put(ComponentPreset.PARTNO, "partno");
+ presetspec.put(ComponentPreset.LENGTH, 2.0);
+ presetspec.put(ComponentPreset.INNER_DIAMETER, 1.0);
+ presetspec.put(ComponentPreset.THICKNESS, 0.5);
ComponentPreset preset = ComponentPresetFactory.create(presetspec);
-
- assertEquals(2.0,preset.get(ComponentPreset.OUTER_DIAMETER).doubleValue(),0.0);
+
+ assertEquals(2.0, preset.get(ComponentPreset.OUTER_DIAMETER).doubleValue(), 0.0);
}
-
+
@Test
public void testComputeThickness() throws Exception {
TypedPropertyMap presetspec = new TypedPropertyMap();
presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.ENGINE_BLOCK);
- presetspec.put( ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
- presetspec.put( ComponentPreset.PARTNO, "partno");
- presetspec.put( ComponentPreset.LENGTH, 2.0);
- presetspec.put( ComponentPreset.OUTER_DIAMETER, 2.0);
- presetspec.put( ComponentPreset.INNER_DIAMETER, 1.0);
+ presetspec.put(ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
+ presetspec.put(ComponentPreset.PARTNO, "partno");
+ presetspec.put(ComponentPreset.LENGTH, 2.0);
+ presetspec.put(ComponentPreset.OUTER_DIAMETER, 2.0);
+ presetspec.put(ComponentPreset.INNER_DIAMETER, 1.0);
ComponentPreset preset = ComponentPresetFactory.create(presetspec);
-
- assertEquals(0.5,preset.get(ComponentPreset.THICKNESS).doubleValue(),0.0);
+
+ assertEquals(0.5, preset.get(ComponentPreset.THICKNESS).doubleValue(), 0.0);
}
-
+
@Test
public void testComputeThicknessLooses() throws Exception {
// If all OUTER_DIAMETER, INNER_DIAMETER and THICKNESS are
// specified, THICKNESS is recomputed.
TypedPropertyMap presetspec = new TypedPropertyMap();
presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.ENGINE_BLOCK);
- presetspec.put( ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
- presetspec.put( ComponentPreset.PARTNO, "partno");
- presetspec.put( ComponentPreset.LENGTH, 2.0);
- presetspec.put( ComponentPreset.OUTER_DIAMETER, 2.0);
- presetspec.put( ComponentPreset.INNER_DIAMETER, 1.0);
- presetspec.put( ComponentPreset.THICKNESS, 15.0);
+ presetspec.put(ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
+ presetspec.put(ComponentPreset.PARTNO, "partno");
+ presetspec.put(ComponentPreset.LENGTH, 2.0);
+ presetspec.put(ComponentPreset.OUTER_DIAMETER, 2.0);
+ presetspec.put(ComponentPreset.INNER_DIAMETER, 1.0);
+ presetspec.put(ComponentPreset.THICKNESS, 15.0);
ComponentPreset preset = ComponentPresetFactory.create(presetspec);
-
- assertEquals(0.5,preset.get(ComponentPreset.THICKNESS).doubleValue(),0.0);
+
+ assertEquals(0.5, preset.get(ComponentPreset.THICKNESS).doubleValue(), 0.0);
}
-
+
@Test
public void testComputeDensityNoMaterial() throws Exception {
TypedPropertyMap presetspec = new TypedPropertyMap();
presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.ENGINE_BLOCK);
- presetspec.put( ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
- presetspec.put( ComponentPreset.PARTNO, "partno");
- presetspec.put( ComponentPreset.LENGTH, 2.0);
- presetspec.put( ComponentPreset.OUTER_DIAMETER, 2.0);
- presetspec.put( ComponentPreset.INNER_DIAMETER, 1.0);
- presetspec.put( ComponentPreset.MASS, 100.0);
+ presetspec.put(ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
+ presetspec.put(ComponentPreset.PARTNO, "partno");
+ presetspec.put(ComponentPreset.LENGTH, 2.0);
+ presetspec.put(ComponentPreset.OUTER_DIAMETER, 2.0);
+ presetspec.put(ComponentPreset.INNER_DIAMETER, 1.0);
+ presetspec.put(ComponentPreset.MASS, 100.0);
ComponentPreset preset = ComponentPresetFactory.create(presetspec);
-
+
// Compute the volume by hand here using a slightly different formula from
// the real implementation. The magic numbers are based on the
// constants put into the presetspec above.
- double volume = /*outer area*/ (Math.PI * 1.0) - /* inner area */ (Math.PI * .25);
+ double volume = /*outer area*/(Math.PI * 1.0) - /* inner area */(Math.PI * .25);
volume *= 2.0; /* times length */
double density = 100.0 / volume;
- assertEquals("EngineBlockCustom",preset.get(ComponentPreset.MATERIAL).getName());
- assertEquals(density,preset.get(ComponentPreset.MATERIAL).getDensity(),0.0005);
+ assertEquals("EngineBlockCustom", preset.get(ComponentPreset.MATERIAL).getName());
+ assertEquals(density, preset.get(ComponentPreset.MATERIAL).getDensity(), 0.0005);
}
-
+
@Test
public void testMaterial() throws Exception {
TypedPropertyMap presetspec = new TypedPropertyMap();
presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.ENGINE_BLOCK);
- presetspec.put( ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
- presetspec.put( ComponentPreset.PARTNO, "partno");
- presetspec.put( ComponentPreset.LENGTH, 2.0);
- presetspec.put( ComponentPreset.OUTER_DIAMETER, 2.0);
- presetspec.put( ComponentPreset.INNER_DIAMETER, 1.0);
- presetspec.put( ComponentPreset.MATERIAL, Material.newUserMaterial(Material.Type.BULK,"test", 2.0));
+ presetspec.put(ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
+ presetspec.put(ComponentPreset.PARTNO, "partno");
+ presetspec.put(ComponentPreset.LENGTH, 2.0);
+ presetspec.put(ComponentPreset.OUTER_DIAMETER, 2.0);
+ presetspec.put(ComponentPreset.INNER_DIAMETER, 1.0);
+ presetspec.put(ComponentPreset.MATERIAL, Material.newMaterial(Material.Type.BULK, "test", 2.0, true));
ComponentPreset preset = ComponentPresetFactory.create(presetspec);
-
- assertEquals("test",preset.get(ComponentPreset.MATERIAL).getName());
- assertEquals(2.0,preset.get(ComponentPreset.MATERIAL).getDensity(),0.0005);
+
+ assertEquals("test", preset.get(ComponentPreset.MATERIAL).getName());
+ assertEquals(2.0, preset.get(ComponentPreset.MATERIAL).getDensity(), 0.0005);
}
-
+
@Test
public void testComputeDensityWithMaterial() throws Exception {
TypedPropertyMap presetspec = new TypedPropertyMap();
presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.ENGINE_BLOCK);
- presetspec.put( ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
- presetspec.put( ComponentPreset.PARTNO, "partno");
- presetspec.put( ComponentPreset.LENGTH, 2.0);
- presetspec.put( ComponentPreset.OUTER_DIAMETER, 2.0);
- presetspec.put( ComponentPreset.INNER_DIAMETER, 1.0);
- presetspec.put( ComponentPreset.MASS, 100.0);
- presetspec.put( ComponentPreset.MATERIAL, Material.newUserMaterial(Material.Type.BULK,"test", 2.0));
+ presetspec.put(ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
+ presetspec.put(ComponentPreset.PARTNO, "partno");
+ presetspec.put(ComponentPreset.LENGTH, 2.0);
+ presetspec.put(ComponentPreset.OUTER_DIAMETER, 2.0);
+ presetspec.put(ComponentPreset.INNER_DIAMETER, 1.0);
+ presetspec.put(ComponentPreset.MASS, 100.0);
+ presetspec.put(ComponentPreset.MATERIAL, Material.newMaterial(Material.Type.BULK, "test", 2.0, true));
ComponentPreset preset = ComponentPresetFactory.create(presetspec);
-
+
// Compute the volume by hand here using a slightly different formula from
// the real implementation. The magic numbers are based on the
// constants put into the presetspec above.
- double volume = /*outer area*/ (Math.PI * 1.0) - /* inner area */ (Math.PI * .25);
+ double volume = /*outer area*/(Math.PI * 1.0) - /* inner area */(Math.PI * .25);
volume *= 2.0; /* times length */
double density = 100.0 / volume;
- assertEquals("test",preset.get(ComponentPreset.MATERIAL).getName());
- assertEquals(density,preset.get(ComponentPreset.MATERIAL).getDensity(),0.0005);
+ assertEquals("test", preset.get(ComponentPreset.MATERIAL).getName());
+ assertEquals(density, preset.get(ComponentPreset.MATERIAL).getDensity(), 0.0005);
}
-
+
}
import static org.junit.Assert.*;
import net.sf.openrocket.material.Material;
import net.sf.openrocket.motor.Manufacturer;
-import net.sf.openrocket.rocketcomponent.LaunchLug;
import net.sf.openrocket.rocketcomponent.ExternalComponent.Finish;
+import net.sf.openrocket.rocketcomponent.LaunchLug;
import net.sf.openrocket.util.BaseTestCase.BaseTestCase;
import org.junit.Before;
*
*/
public class LaunchLugComponentTests extends BaseTestCase {
-
+
ComponentPreset preset;
@Before
public void createPreset() throws Exception {
TypedPropertyMap presetspec = new TypedPropertyMap();
presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.LAUNCH_LUG);
- presetspec.put( ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
- presetspec.put( ComponentPreset.PARTNO, "partno");
- presetspec.put( ComponentPreset.LENGTH, 2.0);
- presetspec.put( ComponentPreset.OUTER_DIAMETER, 2.0);
- presetspec.put( ComponentPreset.INNER_DIAMETER, 1.0);
- presetspec.put( ComponentPreset.MASS, 100.0);
+ presetspec.put(ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
+ presetspec.put(ComponentPreset.PARTNO, "partno");
+ presetspec.put(ComponentPreset.LENGTH, 2.0);
+ presetspec.put(ComponentPreset.OUTER_DIAMETER, 2.0);
+ presetspec.put(ComponentPreset.INNER_DIAMETER, 1.0);
+ presetspec.put(ComponentPreset.MASS, 100.0);
preset = ComponentPresetFactory.create(presetspec);
}
-
+
@Test
public void testComponentType() {
LaunchLug bt = new LaunchLug();
- assertSame( ComponentPreset.Type.LAUNCH_LUG, bt.getPresetType() );
+ assertSame(ComponentPreset.Type.LAUNCH_LUG, bt.getPresetType());
}
@Test
bt.loadPreset(preset);
- assertEquals( 2.0, bt.getLength(), 0.0 );
- assertEquals( 1.0, bt.getOuterRadius(), 0.0 );
- assertEquals( 0.5, bt.getInnerRadius(), 0.0 );
+ assertEquals(2.0, bt.getLength(), 0.0);
+ assertEquals(1.0, bt.getOuterRadius(), 0.0);
+ assertEquals(0.5, bt.getInnerRadius(), 0.0);
- assertSame( preset.get( ComponentPreset.MATERIAL), bt.getMaterial() );
- assertEquals( 100.0, bt.getMass(), 0.05);
+ assertSame(preset.get(ComponentPreset.MATERIAL), bt.getMaterial());
+ assertEquals(100.0, bt.getMass(), 0.05);
}
@Test
LaunchLug bt = new LaunchLug();
bt.loadPreset(preset);
-
+
bt.setLength(1.0);
- assertSame( preset, bt.getPresetComponent() );
+ assertSame(preset, bt.getPresetComponent());
}
-
+
@Test
public void changeODClearsPreset() {
LaunchLug bt = new LaunchLug();
bt.loadPreset(preset);
-
+
bt.setOuterRadius(2.0);
- assertNull( bt.getPresetComponent() );
+ assertNull(bt.getPresetComponent());
}
-
+
@Test
public void changeIDClearsPreset() {
LaunchLug bt = new LaunchLug();
bt.loadPreset(preset);
-
+
bt.setInnerRadius(0.75);
- assertNull( bt.getPresetComponent() );
+ assertNull(bt.getPresetComponent());
}
-
+
@Test
public void changeThicknessClearsPreset() {
LaunchLug bt = new LaunchLug();
bt.loadPreset(preset);
-
+
bt.setThickness(0.1);
- assertNull( bt.getPresetComponent() );
+ assertNull(bt.getPresetComponent());
}
-
+
@Test
public void changeMaterialClearsPreset() {
LaunchLug bt = new LaunchLug();
bt.loadPreset(preset);
-
- bt.setMaterial( Material.newUserMaterial(Material.Type.BULK,"new", 1.0));
- assertNull( bt.getPresetComponent() );
+ bt.setMaterial(Material.newMaterial(Material.Type.BULK, "new", 1.0, true));
+
+ assertNull(bt.getPresetComponent());
}
-
+
@Test
public void changeFinishLeavesPreset() {
LaunchLug bt = new LaunchLug();
bt.loadPreset(preset);
-
- bt.setFinish( Finish.POLISHED );
- assertSame( preset, bt.getPresetComponent() );
+ bt.setFinish(Finish.POLISHED);
+
+ assertSame(preset, bt.getPresetComponent());
}
-
+
}
*
*/
public class LaunchLugPresetTests {
-
+
@Test
public void testManufacturerRequired() {
try {
TypedPropertyMap presetspec = new TypedPropertyMap();
presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.LAUNCH_LUG);
ComponentPresetFactory.create(presetspec);
- } catch ( InvalidComponentPresetException ex ) {
- PresetAssertHelper.assertInvalidPresetException( ex,
+ } catch (InvalidComponentPresetException ex) {
+ PresetAssertHelper.assertInvalidPresetException(ex,
new TypedKey<?>[] {
- ComponentPreset.MANUFACTURER,
- ComponentPreset.PARTNO,
- ComponentPreset.LENGTH
- },
- new String[] {
- "No Manufacturer specified",
- "No PartNo specified",
- "No Length specified",
- "Preset dimensions underspecified"
- }
+ ComponentPreset.MANUFACTURER,
+ ComponentPreset.PARTNO,
+ ComponentPreset.LENGTH
+ },
+ new String[] {
+ "No Manufacturer specified",
+ "No PartNo specified",
+ "No Length specified",
+ "Preset dimensions underspecified"
+ }
);
}
}
-
+
@Test
public void testPartNoRequired() {
try {
TypedPropertyMap presetspec = new TypedPropertyMap();
presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.LAUNCH_LUG);
- presetspec.put( ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
+ presetspec.put(ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
ComponentPresetFactory.create(presetspec);
- } catch ( InvalidComponentPresetException ex ) {
- PresetAssertHelper.assertInvalidPresetException( ex,
+ } catch (InvalidComponentPresetException ex) {
+ PresetAssertHelper.assertInvalidPresetException(ex,
new TypedKey<?>[] {
- ComponentPreset.PARTNO,
- ComponentPreset.LENGTH
- },
- new String[] {
- "No PartNo specified",
- "No Length specified",
- "Preset dimensions underspecified"
- }
+ ComponentPreset.PARTNO,
+ ComponentPreset.LENGTH
+ },
+ new String[] {
+ "No PartNo specified",
+ "No Length specified",
+ "Preset dimensions underspecified"
+ }
);
}
}
-
+
@Test
public void testLengthRequired() {
try {
TypedPropertyMap presetspec = new TypedPropertyMap();
presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.LAUNCH_LUG);
- presetspec.put( ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
- presetspec.put( ComponentPreset.PARTNO, "partno");
+ presetspec.put(ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
+ presetspec.put(ComponentPreset.PARTNO, "partno");
ComponentPresetFactory.create(presetspec);
- } catch ( InvalidComponentPresetException ex ) {
- PresetAssertHelper.assertInvalidPresetException( ex,
+ } catch (InvalidComponentPresetException ex) {
+ PresetAssertHelper.assertInvalidPresetException(ex,
new TypedKey<?>[] {
ComponentPreset.LENGTH
- },
- new String[] {
- "No Length specified",
- "Preset dimensions underspecified"
- }
+ },
+ new String[] {
+ "No Length specified",
+ "Preset dimensions underspecified"
+ }
);
}
}
-
+
@Test
public void testOnlyOuterDiameter() {
try {
TypedPropertyMap presetspec = new TypedPropertyMap();
presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.LAUNCH_LUG);
- presetspec.put( ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
- presetspec.put( ComponentPreset.PARTNO, "partno");
- presetspec.put( ComponentPreset.LENGTH, 2.0);
- presetspec.put( ComponentPreset.OUTER_DIAMETER, 2.0);
+ presetspec.put(ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
+ presetspec.put(ComponentPreset.PARTNO, "partno");
+ presetspec.put(ComponentPreset.LENGTH, 2.0);
+ presetspec.put(ComponentPreset.OUTER_DIAMETER, 2.0);
ComponentPresetFactory.create(presetspec);
- } catch ( InvalidComponentPresetException ex ) {
- PresetAssertHelper.assertInvalidPresetException( ex,
+ } catch (InvalidComponentPresetException ex) {
+ PresetAssertHelper.assertInvalidPresetException(ex,
null,
- new String[] {
+ new String[] {
"Preset dimensions underspecified"
- }
+ }
);
}
}
-
+
@Test
public void testOnlyInnerDiameter() {
try {
TypedPropertyMap presetspec = new TypedPropertyMap();
presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.LAUNCH_LUG);
- presetspec.put( ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
- presetspec.put( ComponentPreset.PARTNO, "partno");
- presetspec.put( ComponentPreset.LENGTH, 2.0);
- presetspec.put( ComponentPreset.INNER_DIAMETER, 2.0);
+ presetspec.put(ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
+ presetspec.put(ComponentPreset.PARTNO, "partno");
+ presetspec.put(ComponentPreset.LENGTH, 2.0);
+ presetspec.put(ComponentPreset.INNER_DIAMETER, 2.0);
ComponentPresetFactory.create(presetspec);
- } catch ( InvalidComponentPresetException ex ) {
- PresetAssertHelper.assertInvalidPresetException( ex,
+ } catch (InvalidComponentPresetException ex) {
+ PresetAssertHelper.assertInvalidPresetException(ex,
null,
- new String[] {
+ new String[] {
"Preset dimensions underspecified"
- }
+ }
);
}
}
-
+
@Test
public void testOnlyThicknessDiameter() {
try {
TypedPropertyMap presetspec = new TypedPropertyMap();
presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.LAUNCH_LUG);
- presetspec.put( ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
- presetspec.put( ComponentPreset.PARTNO, "partno");
- presetspec.put( ComponentPreset.LENGTH, 2.0);
- presetspec.put( ComponentPreset.THICKNESS, 2.0);
+ presetspec.put(ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
+ presetspec.put(ComponentPreset.PARTNO, "partno");
+ presetspec.put(ComponentPreset.LENGTH, 2.0);
+ presetspec.put(ComponentPreset.THICKNESS, 2.0);
ComponentPresetFactory.create(presetspec);
- } catch ( InvalidComponentPresetException ex ) {
- PresetAssertHelper.assertInvalidPresetException( ex,
+ } catch (InvalidComponentPresetException ex) {
+ PresetAssertHelper.assertInvalidPresetException(ex,
null,
- new String[] {
+ new String[] {
"Preset dimensions underspecified"
- }
+ }
);
}
}
-
+
@Test
public void testComputeInnerDiameter() throws Exception {
TypedPropertyMap presetspec = new TypedPropertyMap();
presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.LAUNCH_LUG);
- presetspec.put( ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
- presetspec.put( ComponentPreset.PARTNO, "partno");
- presetspec.put( ComponentPreset.LENGTH, 2.0);
- presetspec.put( ComponentPreset.OUTER_DIAMETER, 2.0);
- presetspec.put( ComponentPreset.THICKNESS, 0.5);
+ presetspec.put(ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
+ presetspec.put(ComponentPreset.PARTNO, "partno");
+ presetspec.put(ComponentPreset.LENGTH, 2.0);
+ presetspec.put(ComponentPreset.OUTER_DIAMETER, 2.0);
+ presetspec.put(ComponentPreset.THICKNESS, 0.5);
ComponentPreset preset = ComponentPresetFactory.create(presetspec);
-
- assertEquals(1.0,preset.get(ComponentPreset.INNER_DIAMETER).doubleValue(),0.0);
+
+ assertEquals(1.0, preset.get(ComponentPreset.INNER_DIAMETER).doubleValue(), 0.0);
}
-
+
@Test
public void testComputeOuterDiameter() throws Exception {
TypedPropertyMap presetspec = new TypedPropertyMap();
presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.LAUNCH_LUG);
- presetspec.put( ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
- presetspec.put( ComponentPreset.PARTNO, "partno");
- presetspec.put( ComponentPreset.LENGTH, 2.0);
- presetspec.put( ComponentPreset.INNER_DIAMETER, 1.0);
- presetspec.put( ComponentPreset.THICKNESS, 0.5);
+ presetspec.put(ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
+ presetspec.put(ComponentPreset.PARTNO, "partno");
+ presetspec.put(ComponentPreset.LENGTH, 2.0);
+ presetspec.put(ComponentPreset.INNER_DIAMETER, 1.0);
+ presetspec.put(ComponentPreset.THICKNESS, 0.5);
ComponentPreset preset = ComponentPresetFactory.create(presetspec);
-
- assertEquals(2.0,preset.get(ComponentPreset.OUTER_DIAMETER).doubleValue(),0.0);
+
+ assertEquals(2.0, preset.get(ComponentPreset.OUTER_DIAMETER).doubleValue(), 0.0);
}
-
+
@Test
public void testComputeThickness() throws Exception {
TypedPropertyMap presetspec = new TypedPropertyMap();
presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.LAUNCH_LUG);
- presetspec.put( ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
- presetspec.put( ComponentPreset.PARTNO, "partno");
- presetspec.put( ComponentPreset.LENGTH, 2.0);
- presetspec.put( ComponentPreset.OUTER_DIAMETER, 2.0);
- presetspec.put( ComponentPreset.INNER_DIAMETER, 1.0);
+ presetspec.put(ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
+ presetspec.put(ComponentPreset.PARTNO, "partno");
+ presetspec.put(ComponentPreset.LENGTH, 2.0);
+ presetspec.put(ComponentPreset.OUTER_DIAMETER, 2.0);
+ presetspec.put(ComponentPreset.INNER_DIAMETER, 1.0);
ComponentPreset preset = ComponentPresetFactory.create(presetspec);
-
- assertEquals(0.5,preset.get(ComponentPreset.THICKNESS).doubleValue(),0.0);
+
+ assertEquals(0.5, preset.get(ComponentPreset.THICKNESS).doubleValue(), 0.0);
}
-
+
@Test
public void testComputeThicknessLooses() throws Exception {
// If all OUTER_DIAMETER, INNER_DIAMETER and THICKNESS are
// specified, THICKNESS is recomputed.
TypedPropertyMap presetspec = new TypedPropertyMap();
presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.LAUNCH_LUG);
- presetspec.put( ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
- presetspec.put( ComponentPreset.PARTNO, "partno");
- presetspec.put( ComponentPreset.LENGTH, 2.0);
- presetspec.put( ComponentPreset.OUTER_DIAMETER, 2.0);
- presetspec.put( ComponentPreset.INNER_DIAMETER, 1.0);
- presetspec.put( ComponentPreset.THICKNESS, 15.0);
+ presetspec.put(ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
+ presetspec.put(ComponentPreset.PARTNO, "partno");
+ presetspec.put(ComponentPreset.LENGTH, 2.0);
+ presetspec.put(ComponentPreset.OUTER_DIAMETER, 2.0);
+ presetspec.put(ComponentPreset.INNER_DIAMETER, 1.0);
+ presetspec.put(ComponentPreset.THICKNESS, 15.0);
ComponentPreset preset = ComponentPresetFactory.create(presetspec);
-
- assertEquals(0.5,preset.get(ComponentPreset.THICKNESS).doubleValue(),0.0);
+
+ assertEquals(0.5, preset.get(ComponentPreset.THICKNESS).doubleValue(), 0.0);
}
-
+
@Test
public void testComputeDensityNoMaterial() throws Exception {
TypedPropertyMap presetspec = new TypedPropertyMap();
presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.LAUNCH_LUG);
- presetspec.put( ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
- presetspec.put( ComponentPreset.PARTNO, "partno");
- presetspec.put( ComponentPreset.LENGTH, 2.0);
- presetspec.put( ComponentPreset.OUTER_DIAMETER, 2.0);
- presetspec.put( ComponentPreset.INNER_DIAMETER, 1.0);
- presetspec.put( ComponentPreset.MASS, 100.0);
+ presetspec.put(ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
+ presetspec.put(ComponentPreset.PARTNO, "partno");
+ presetspec.put(ComponentPreset.LENGTH, 2.0);
+ presetspec.put(ComponentPreset.OUTER_DIAMETER, 2.0);
+ presetspec.put(ComponentPreset.INNER_DIAMETER, 1.0);
+ presetspec.put(ComponentPreset.MASS, 100.0);
ComponentPreset preset = ComponentPresetFactory.create(presetspec);
-
+
// Compute the volume by hand here using a slightly different formula from
// the real implementation. The magic numbers are based on the
// constants put into the presetspec above.
- double volume = /*outer area*/ (Math.PI * 1.0) - /* inner area */ (Math.PI * .25);
+ double volume = /*outer area*/(Math.PI * 1.0) - /* inner area */(Math.PI * .25);
volume *= 2.0; /* times length */
double density = 100.0 / volume;
- assertEquals("TubeCustom",preset.get(ComponentPreset.MATERIAL).getName());
- assertEquals(density,preset.get(ComponentPreset.MATERIAL).getDensity(),0.0005);
+ assertEquals("TubeCustom", preset.get(ComponentPreset.MATERIAL).getName());
+ assertEquals(density, preset.get(ComponentPreset.MATERIAL).getDensity(), 0.0005);
}
-
+
@Test
public void testMaterial() throws Exception {
TypedPropertyMap presetspec = new TypedPropertyMap();
presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.LAUNCH_LUG);
- presetspec.put( ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
- presetspec.put( ComponentPreset.PARTNO, "partno");
- presetspec.put( ComponentPreset.LENGTH, 2.0);
- presetspec.put( ComponentPreset.OUTER_DIAMETER, 2.0);
- presetspec.put( ComponentPreset.INNER_DIAMETER, 1.0);
- presetspec.put( ComponentPreset.MATERIAL, Material.newUserMaterial(Material.Type.BULK,"test", 2.0));
+ presetspec.put(ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
+ presetspec.put(ComponentPreset.PARTNO, "partno");
+ presetspec.put(ComponentPreset.LENGTH, 2.0);
+ presetspec.put(ComponentPreset.OUTER_DIAMETER, 2.0);
+ presetspec.put(ComponentPreset.INNER_DIAMETER, 1.0);
+ presetspec.put(ComponentPreset.MATERIAL, Material.newMaterial(Material.Type.BULK, "test", 2.0, true));
ComponentPreset preset = ComponentPresetFactory.create(presetspec);
-
- assertEquals("test",preset.get(ComponentPreset.MATERIAL).getName());
- assertEquals(2.0,preset.get(ComponentPreset.MATERIAL).getDensity(),0.0005);
+
+ assertEquals("test", preset.get(ComponentPreset.MATERIAL).getName());
+ assertEquals(2.0, preset.get(ComponentPreset.MATERIAL).getDensity(), 0.0005);
}
-
+
@Test
public void testComputeDensityWithMaterial() throws Exception {
TypedPropertyMap presetspec = new TypedPropertyMap();
presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.LAUNCH_LUG);
- presetspec.put( ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
- presetspec.put( ComponentPreset.PARTNO, "partno");
- presetspec.put( ComponentPreset.LENGTH, 2.0);
- presetspec.put( ComponentPreset.OUTER_DIAMETER, 2.0);
- presetspec.put( ComponentPreset.INNER_DIAMETER, 1.0);
- presetspec.put( ComponentPreset.MASS, 100.0);
- presetspec.put( ComponentPreset.MATERIAL, Material.newUserMaterial(Material.Type.BULK,"test", 2.0));
+ presetspec.put(ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
+ presetspec.put(ComponentPreset.PARTNO, "partno");
+ presetspec.put(ComponentPreset.LENGTH, 2.0);
+ presetspec.put(ComponentPreset.OUTER_DIAMETER, 2.0);
+ presetspec.put(ComponentPreset.INNER_DIAMETER, 1.0);
+ presetspec.put(ComponentPreset.MASS, 100.0);
+ presetspec.put(ComponentPreset.MATERIAL, Material.newMaterial(Material.Type.BULK, "test", 2.0, true));
ComponentPreset preset = ComponentPresetFactory.create(presetspec);
-
+
// Compute the volume by hand here using a slightly different formula from
// the real implementation. The magic numbers are based on the
// constants put into the presetspec above.
- double volume = /*outer area*/ (Math.PI * 1.0) - /* inner area */ (Math.PI * .25);
+ double volume = /*outer area*/(Math.PI * 1.0) - /* inner area */(Math.PI * .25);
volume *= 2.0; /* times length */
double density = 100.0 / volume;
- assertEquals("test",preset.get(ComponentPreset.MATERIAL).getName());
- assertEquals(density,preset.get(ComponentPreset.MATERIAL).getDensity(),0.0005);
+ assertEquals("test", preset.get(ComponentPreset.MATERIAL).getName());
+ assertEquals(density, preset.get(ComponentPreset.MATERIAL).getDensity(), 0.0005);
}
-
+
}
import static org.junit.Assert.*;
import net.sf.openrocket.material.Material;
import net.sf.openrocket.motor.Manufacturer;
+import net.sf.openrocket.rocketcomponent.ExternalComponent.Finish;
import net.sf.openrocket.rocketcomponent.NoseCone;
import net.sf.openrocket.rocketcomponent.Transition;
-import net.sf.openrocket.rocketcomponent.ExternalComponent.Finish;
import net.sf.openrocket.util.BaseTestCase.BaseTestCase;
import org.junit.Before;
*
*/
public class NoseConeComponentTests extends BaseTestCase {
-
+
ComponentPreset preset;
@Before
public void createPreset() throws Exception {
TypedPropertyMap presetspec = new TypedPropertyMap();
presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.NOSE_CONE);
- presetspec.put( ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
- presetspec.put( ComponentPreset.PARTNO, "partno");
- presetspec.put( ComponentPreset.LENGTH, 2.0);
- presetspec.put( ComponentPreset.SHAPE, Transition.Shape.CONICAL);
- presetspec.put( ComponentPreset.AFT_OUTER_DIAMETER, 2.0);
- presetspec.put( ComponentPreset.AFT_SHOULDER_LENGTH, 1.0);
- presetspec.put( ComponentPreset.AFT_SHOULDER_DIAMETER, 1.0);
- presetspec.put( ComponentPreset.FILLED, true);
- presetspec.put( ComponentPreset.MASS, 100.0);
- presetspec.put( ComponentPreset.MATERIAL, Material.newUserMaterial(Material.Type.BULK,"test", 2.0));
+ presetspec.put(ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
+ presetspec.put(ComponentPreset.PARTNO, "partno");
+ presetspec.put(ComponentPreset.LENGTH, 2.0);
+ presetspec.put(ComponentPreset.SHAPE, Transition.Shape.CONICAL);
+ presetspec.put(ComponentPreset.AFT_OUTER_DIAMETER, 2.0);
+ presetspec.put(ComponentPreset.AFT_SHOULDER_LENGTH, 1.0);
+ presetspec.put(ComponentPreset.AFT_SHOULDER_DIAMETER, 1.0);
+ presetspec.put(ComponentPreset.FILLED, true);
+ presetspec.put(ComponentPreset.MASS, 100.0);
+ presetspec.put(ComponentPreset.MATERIAL, Material.newMaterial(Material.Type.BULK, "test", 2.0, true));
preset = ComponentPresetFactory.create(presetspec);
}
-
+
@Test
public void testComponentType() {
NoseCone nc = new NoseCone();
- assertSame( ComponentPreset.Type.NOSE_CONE, nc.getPresetType() );
+ assertSame(ComponentPreset.Type.NOSE_CONE, nc.getPresetType());
}
@Test
nc.loadPreset(preset);
- assertEquals( 2.0, nc.getLength(), 0.0 );
- assertSame( Transition.Shape.CONICAL, nc.getType() );
- assertEquals( 1.0, nc.getAftRadius(), 0.0 );
- assertEquals( 0.0, nc.getForeShoulderLength(), 0.0 );
- assertEquals( 0.0, nc.getForeShoulderRadius(), 0.0 );
- assertEquals( 1.0, nc.getAftShoulderLength(), 0.0 );
- assertEquals( 0.5, nc.getAftShoulderRadius(), 0.0 );
- assertEquals( 0.5, nc.getAftShoulderThickness(), 0.0 );
-
- assertFalse( nc.isForeRadiusAutomatic() );
- assertFalse( nc.isAftRadiusAutomatic() );
- assertTrue( nc.isFilled() );
-
- assertSame( preset.get( ComponentPreset.MATERIAL), nc.getMaterial() );
- assertEquals( 100.0, nc.getMass(), 0.05);
+ assertEquals(2.0, nc.getLength(), 0.0);
+ assertSame(Transition.Shape.CONICAL, nc.getType());
+ assertEquals(1.0, nc.getAftRadius(), 0.0);
+ assertEquals(0.0, nc.getForeShoulderLength(), 0.0);
+ assertEquals(0.0, nc.getForeShoulderRadius(), 0.0);
+ assertEquals(1.0, nc.getAftShoulderLength(), 0.0);
+ assertEquals(0.5, nc.getAftShoulderRadius(), 0.0);
+ assertEquals(0.5, nc.getAftShoulderThickness(), 0.0);
+
+ assertFalse(nc.isForeRadiusAutomatic());
+ assertFalse(nc.isAftRadiusAutomatic());
+ assertTrue(nc.isFilled());
+
+ assertSame(preset.get(ComponentPreset.MATERIAL), nc.getMaterial());
+ assertEquals(100.0, nc.getMass(), 0.05);
}
@Test
NoseCone nc = new NoseCone();
nc.loadPreset(preset);
-
+
nc.setLength(1.0);
- assertNull( nc.getPresetComponent() );
+ assertNull(nc.getPresetComponent());
}
-
+
@Test
public void changeAftRadiusClearsPreset() {
NoseCone nc = new NoseCone();
nc.loadPreset(preset);
-
+
nc.setAftRadius(2.0);
- assertNull( nc.getPresetComponent() );
+ assertNull(nc.getPresetComponent());
}
-
+
@Test
public void changeAftRadiusAutomaticClearsPreset() {
NoseCone nc = new NoseCone();
nc.loadPreset(preset);
-
+
nc.setAftRadiusAutomatic(true);
- assertNull( nc.getPresetComponent() );
+ assertNull(nc.getPresetComponent());
}
-
+
@Test
public void changeAftShoulderRadiusClearsPreset() {
NoseCone nc = new NoseCone();
nc.loadPreset(preset);
-
+
nc.setAftShoulderRadius(2.0);
- assertNull( nc.getPresetComponent() );
+ assertNull(nc.getPresetComponent());
}
-
+
@Test
public void changeAftSholderLengthLeavesPreset() {
NoseCone nc = new NoseCone();
nc.loadPreset(preset);
-
+
nc.setAftShoulderLength(2.0);
- assertSame( preset, nc.getPresetComponent() );
+ assertSame(preset, nc.getPresetComponent());
}
-
+
@Test
public void changeThicknessClearsPreset() {
NoseCone nc = new NoseCone();
nc.loadPreset(preset);
-
+
nc.setThickness(0.1);
- assertNull( nc.getPresetComponent() );
+ assertNull(nc.getPresetComponent());
}
-
-
+
+
@Test
public void changeFilledClearsPreset() {
NoseCone nc = new NoseCone();
nc.loadPreset(preset);
-
+
nc.setFilled(false);
- assertNull( nc.getPresetComponent() );
+ assertNull(nc.getPresetComponent());
}
-
+
@Test
public void changeMaterialClearsPreset() {
NoseCone nc = new NoseCone();
nc.loadPreset(preset);
-
- nc.setMaterial( Material.newUserMaterial(Material.Type.BULK,"new", 1.0));
- assertNull( nc.getPresetComponent() );
+ nc.setMaterial(Material.newMaterial(Material.Type.BULK, "new", 1.0, true));
+
+ assertNull(nc.getPresetComponent());
}
-
+
@Test
public void changeFinishLeavesPreset() {
NoseCone nc = new NoseCone();
nc.loadPreset(preset);
-
- nc.setFinish( Finish.POLISHED );
- assertSame( preset, nc.getPresetComponent() );
+ nc.setFinish(Finish.POLISHED);
+
+ assertSame(preset, nc.getPresetComponent());
}
-
+
}
*
*/
public class NoseConePresetTests extends BaseTestCase {
-
+
@Test
public void testManufacturerRequired() {
try {
TypedPropertyMap presetspec = new TypedPropertyMap();
presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.NOSE_CONE);
ComponentPresetFactory.create(presetspec);
- } catch ( InvalidComponentPresetException ex ) {
- PresetAssertHelper.assertInvalidPresetException( ex,
+ } catch (InvalidComponentPresetException ex) {
+ PresetAssertHelper.assertInvalidPresetException(ex,
new TypedKey<?>[] {
- ComponentPreset.MANUFACTURER,
- ComponentPreset.PARTNO,
- ComponentPreset.LENGTH,
- ComponentPreset.AFT_OUTER_DIAMETER,
- ComponentPreset.SHAPE
- },
- new String[] {
- "No Manufacturer specified",
- "No PartNo specified",
- "No Length specified",
- "No AftOuterDiameter specified",
- "No Shape specified"
- }
+ ComponentPreset.MANUFACTURER,
+ ComponentPreset.PARTNO,
+ ComponentPreset.LENGTH,
+ ComponentPreset.AFT_OUTER_DIAMETER,
+ ComponentPreset.SHAPE
+ },
+ new String[] {
+ "No Manufacturer specified",
+ "No PartNo specified",
+ "No Length specified",
+ "No AftOuterDiameter specified",
+ "No Shape specified"
+ }
);
}
}
-
+
@Test
public void testPartNoRequired() {
try {
TypedPropertyMap presetspec = new TypedPropertyMap();
presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.NOSE_CONE);
- presetspec.put( ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
+ presetspec.put(ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
ComponentPresetFactory.create(presetspec);
- } catch ( InvalidComponentPresetException ex ) {
- PresetAssertHelper.assertInvalidPresetException( ex,
+ } catch (InvalidComponentPresetException ex) {
+ PresetAssertHelper.assertInvalidPresetException(ex,
new TypedKey<?>[] {
- ComponentPreset.PARTNO,
- ComponentPreset.LENGTH,
- ComponentPreset.AFT_OUTER_DIAMETER,
- ComponentPreset.SHAPE
- },
- new String[] {
- "No PartNo specified",
- "No Length specified",
- "No AftOuterDiameter specified",
- "No Shape specified"
- }
+ ComponentPreset.PARTNO,
+ ComponentPreset.LENGTH,
+ ComponentPreset.AFT_OUTER_DIAMETER,
+ ComponentPreset.SHAPE
+ },
+ new String[] {
+ "No PartNo specified",
+ "No Length specified",
+ "No AftOuterDiameter specified",
+ "No Shape specified"
+ }
);
}
}
-
+
@Test
public void testLengthRequired() {
try {
TypedPropertyMap presetspec = new TypedPropertyMap();
presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.NOSE_CONE);
- presetspec.put( ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
- presetspec.put( ComponentPreset.PARTNO, "partno");
+ presetspec.put(ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
+ presetspec.put(ComponentPreset.PARTNO, "partno");
ComponentPresetFactory.create(presetspec);
- } catch ( InvalidComponentPresetException ex ) {
- PresetAssertHelper.assertInvalidPresetException( ex,
+ } catch (InvalidComponentPresetException ex) {
+ PresetAssertHelper.assertInvalidPresetException(ex,
new TypedKey<?>[] {
- ComponentPreset.LENGTH,
- ComponentPreset.AFT_OUTER_DIAMETER,
- ComponentPreset.SHAPE
- },
- new String[] {
- "No Length specified",
- "No AftOuterDiameter specified",
- "No Shape specified"
- }
+ ComponentPreset.LENGTH,
+ ComponentPreset.AFT_OUTER_DIAMETER,
+ ComponentPreset.SHAPE
+ },
+ new String[] {
+ "No Length specified",
+ "No AftOuterDiameter specified",
+ "No Shape specified"
+ }
);
}
}
-
+
@Test
public void testShapeRequired() {
try {
TypedPropertyMap presetspec = new TypedPropertyMap();
presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.NOSE_CONE);
- presetspec.put( ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
- presetspec.put( ComponentPreset.PARTNO, "partno");
- presetspec.put( ComponentPreset.LENGTH, 2.0);
+ presetspec.put(ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
+ presetspec.put(ComponentPreset.PARTNO, "partno");
+ presetspec.put(ComponentPreset.LENGTH, 2.0);
ComponentPresetFactory.create(presetspec);
- } catch ( InvalidComponentPresetException ex ) {
- PresetAssertHelper.assertInvalidPresetException( ex,
+ } catch (InvalidComponentPresetException ex) {
+ PresetAssertHelper.assertInvalidPresetException(ex,
new TypedKey<?>[] {
- ComponentPreset.AFT_OUTER_DIAMETER,
- ComponentPreset.SHAPE
- },
- new String[] {
- "No AftOuterDiameter specified",
- "No Shape specified"
- }
+ ComponentPreset.AFT_OUTER_DIAMETER,
+ ComponentPreset.SHAPE
+ },
+ new String[] {
+ "No AftOuterDiameter specified",
+ "No Shape specified"
+ }
);
}
}
-
+
@Test
public void testAftOuterDiameterRequired() {
try {
TypedPropertyMap presetspec = new TypedPropertyMap();
presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.NOSE_CONE);
- presetspec.put( ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
- presetspec.put( ComponentPreset.PARTNO, "partno");
- presetspec.put( ComponentPreset.LENGTH, 2.0);
- presetspec.put( ComponentPreset.SHAPE, Transition.Shape.CONICAL);
+ presetspec.put(ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
+ presetspec.put(ComponentPreset.PARTNO, "partno");
+ presetspec.put(ComponentPreset.LENGTH, 2.0);
+ presetspec.put(ComponentPreset.SHAPE, Transition.Shape.CONICAL);
ComponentPresetFactory.create(presetspec);
- } catch ( InvalidComponentPresetException ex ) {
- PresetAssertHelper.assertInvalidPresetException( ex,
+ } catch (InvalidComponentPresetException ex) {
+ PresetAssertHelper.assertInvalidPresetException(ex,
new TypedKey<?>[] {
ComponentPreset.AFT_OUTER_DIAMETER
- },
- new String[] {
+ },
+ new String[] {
"No AftOuterDiameter specified"
- }
+ }
);
}
}
-
+
@Test
public void testComputeDensityNoMaterial() throws Exception {
TypedPropertyMap presetspec = new TypedPropertyMap();
presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.NOSE_CONE);
- presetspec.put( ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
- presetspec.put( ComponentPreset.PARTNO, "partno");
- presetspec.put( ComponentPreset.LENGTH, 2.0);
- presetspec.put( ComponentPreset.SHAPE, Transition.Shape.CONICAL);
- presetspec.put( ComponentPreset.AFT_OUTER_DIAMETER, 2.0);
- presetspec.put( ComponentPreset.FILLED, true);
- presetspec.put( ComponentPreset.MASS, 100.0);
+ presetspec.put(ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
+ presetspec.put(ComponentPreset.PARTNO, "partno");
+ presetspec.put(ComponentPreset.LENGTH, 2.0);
+ presetspec.put(ComponentPreset.SHAPE, Transition.Shape.CONICAL);
+ presetspec.put(ComponentPreset.AFT_OUTER_DIAMETER, 2.0);
+ presetspec.put(ComponentPreset.FILLED, true);
+ presetspec.put(ComponentPreset.MASS, 100.0);
ComponentPreset preset = ComponentPresetFactory.create(presetspec);
-
+
// constants put into the presetspec above.
- double volume = /*base area*/ Math.PI;
- volume *= 2.0 /* times height */ / 3.0; /* one third */
+ double volume = /*base area*/Math.PI;
+ volume *= 2.0 /* times height *// 3.0; /* one third */
double density = 100.0 / volume;
- assertEquals("NoseConeCustom",preset.get(ComponentPreset.MATERIAL).getName());
+ assertEquals("NoseConeCustom", preset.get(ComponentPreset.MATERIAL).getName());
// note - epsilon is 1% of the simple computation of density
- assertEquals(density,preset.get(ComponentPreset.MATERIAL).getDensity(),0.01*density);
+ assertEquals(density, preset.get(ComponentPreset.MATERIAL).getDensity(), 0.01 * density);
}
-
+
@Test
public void testMaterial() throws Exception {
TypedPropertyMap presetspec = new TypedPropertyMap();
presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.NOSE_CONE);
- presetspec.put( ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
- presetspec.put( ComponentPreset.PARTNO, "partno");
- presetspec.put( ComponentPreset.LENGTH, 2.0);
- presetspec.put( ComponentPreset.SHAPE, Transition.Shape.CONICAL);
- presetspec.put( ComponentPreset.AFT_OUTER_DIAMETER, 2.0);
- presetspec.put( ComponentPreset.MATERIAL, Material.newUserMaterial(Material.Type.BULK,"test", 2.0));
+ presetspec.put(ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
+ presetspec.put(ComponentPreset.PARTNO, "partno");
+ presetspec.put(ComponentPreset.LENGTH, 2.0);
+ presetspec.put(ComponentPreset.SHAPE, Transition.Shape.CONICAL);
+ presetspec.put(ComponentPreset.AFT_OUTER_DIAMETER, 2.0);
+ presetspec.put(ComponentPreset.MATERIAL, Material.newMaterial(Material.Type.BULK, "test", 2.0, true));
ComponentPreset preset = ComponentPresetFactory.create(presetspec);
-
- assertEquals("test",preset.get(ComponentPreset.MATERIAL).getName());
- assertEquals(2.0,preset.get(ComponentPreset.MATERIAL).getDensity(),0.0005);
+
+ assertEquals("test", preset.get(ComponentPreset.MATERIAL).getName());
+ assertEquals(2.0, preset.get(ComponentPreset.MATERIAL).getDensity(), 0.0005);
}
-
+
@Test
public void testComputeDensityWithMaterial() throws Exception {
TypedPropertyMap presetspec = new TypedPropertyMap();
presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.NOSE_CONE);
- presetspec.put( ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
- presetspec.put( ComponentPreset.PARTNO, "partno");
- presetspec.put( ComponentPreset.LENGTH, 2.0);
- presetspec.put( ComponentPreset.SHAPE, Transition.Shape.CONICAL);
- presetspec.put( ComponentPreset.AFT_OUTER_DIAMETER, 2.0);
- presetspec.put( ComponentPreset.FILLED, true);
- presetspec.put( ComponentPreset.MASS, 100.0);
- presetspec.put( ComponentPreset.MATERIAL, Material.newUserMaterial(Material.Type.BULK,"test", 2.0));
+ presetspec.put(ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
+ presetspec.put(ComponentPreset.PARTNO, "partno");
+ presetspec.put(ComponentPreset.LENGTH, 2.0);
+ presetspec.put(ComponentPreset.SHAPE, Transition.Shape.CONICAL);
+ presetspec.put(ComponentPreset.AFT_OUTER_DIAMETER, 2.0);
+ presetspec.put(ComponentPreset.FILLED, true);
+ presetspec.put(ComponentPreset.MASS, 100.0);
+ presetspec.put(ComponentPreset.MATERIAL, Material.newMaterial(Material.Type.BULK, "test", 2.0, true));
ComponentPreset preset = ComponentPresetFactory.create(presetspec);
-
+
// constants put into the presetspec above.
- double volume = /*base area*/ Math.PI;
- volume *= 2.0 /* times height */ / 3.0; /* one third */
+ double volume = /*base area*/Math.PI;
+ volume *= 2.0 /* times height *// 3.0; /* one third */
double density = 100.0 / volume;
- assertEquals("test",preset.get(ComponentPreset.MATERIAL).getName());
+ assertEquals("test", preset.get(ComponentPreset.MATERIAL).getName());
// note - epsilon is 1% of the simple computation of density
- assertEquals(density,preset.get(ComponentPreset.MATERIAL).getDensity(),0.01*density);
+ assertEquals(density, preset.get(ComponentPreset.MATERIAL).getDensity(), 0.01 * density);
}
-
+
}
package net.sf.openrocket.preset;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertSame;
+import static org.junit.Assert.*;
import net.sf.openrocket.material.Material;
import net.sf.openrocket.motor.Manufacturer;
import net.sf.openrocket.rocketcomponent.Parachute;
*
*/
public class ParachuterComponentTests extends BaseTestCase {
-
+
ComponentPreset preset;
@Before
public void createPreset() throws Exception {
TypedPropertyMap presetspec = new TypedPropertyMap();
presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.PARACHUTE);
- presetspec.put( ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
- presetspec.put( ComponentPreset.PARTNO, "partno");
- presetspec.put( ComponentPreset.DIAMETER, 20.0);
- presetspec.put( ComponentPreset.LINE_COUNT, 8);
- presetspec.put( ComponentPreset.LINE_LENGTH, 12.0);
- Material m = Material.newUserMaterial(Material.Type.SURFACE,"testMaterial", 2.0);
- presetspec.put( ComponentPreset.MATERIAL, m);
- m = Material.newUserMaterial(Material.Type.LINE,"testLineMaterial", 3);
- presetspec.put( ComponentPreset.LINE_MATERIAL, m);
+ presetspec.put(ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
+ presetspec.put(ComponentPreset.PARTNO, "partno");
+ presetspec.put(ComponentPreset.DIAMETER, 20.0);
+ presetspec.put(ComponentPreset.LINE_COUNT, 8);
+ presetspec.put(ComponentPreset.LINE_LENGTH, 12.0);
+ Material m = Material.newMaterial(Material.Type.SURFACE, "testMaterial", 2.0, true);
+ presetspec.put(ComponentPreset.MATERIAL, m);
+ m = Material.newMaterial(Material.Type.LINE, "testLineMaterial", 3, true);
+ presetspec.put(ComponentPreset.LINE_MATERIAL, m);
preset = ComponentPresetFactory.create(presetspec);
}
-
+
@Test
public void testComponentType() {
Parachute cr = new Parachute();
- assertSame( ComponentPreset.Type.PARACHUTE, cr.getPresetType() );
+ assertSame(ComponentPreset.Type.PARACHUTE, cr.getPresetType());
}
@Test
cr.loadPreset(preset);
- assertEquals( 20.0, cr.getDiameter(), 0.0 );
- assertEquals( 8, cr.getLineCount(), 0.0 );
- assertEquals( 12.0, cr.getLineLength(), 0.0 );
+ assertEquals(20.0, cr.getDiameter(), 0.0);
+ assertEquals(8, cr.getLineCount(), 0.0);
+ assertEquals(12.0, cr.getLineLength(), 0.0);
- assertSame( preset.get( ComponentPreset.MATERIAL), cr.getMaterial() );
- assertSame( preset.get( ComponentPreset.LINE_MATERIAL), cr.getLineMaterial() );
+ assertSame(preset.get(ComponentPreset.MATERIAL), cr.getMaterial());
+ assertSame(preset.get(ComponentPreset.LINE_MATERIAL), cr.getLineMaterial());
}
@Test
Parachute cr = new Parachute();
cr.loadPreset(preset);
-
+
cr.setDiameter(1.0);
- assertNull( cr.getPresetComponent() );
+ assertNull(cr.getPresetComponent());
}
-
+
@Test
public void changeAreaClearsPreset() {
Parachute cr = new Parachute();
cr.loadPreset(preset);
-
+
cr.setArea(1.0);
- assertNull( cr.getPresetComponent() );
+ assertNull(cr.getPresetComponent());
}
-
+
@Test
public void changeLineCountClearsPreset() {
Parachute cr = new Parachute();
cr.loadPreset(preset);
-
+
cr.setLineCount(12);
- assertNull( cr.getPresetComponent() );
+ assertNull(cr.getPresetComponent());
}
-
+
@Test
public void changeLineLengthLeavesPreset() {
Parachute cr = new Parachute();
cr.loadPreset(preset);
-
+
cr.setLineLength(24);
- assertSame( preset, cr.getPresetComponent() );
+ assertSame(preset, cr.getPresetComponent());
}
-
+
@Test
public void changeMaterialClearsPreset() {
Parachute cr = new Parachute();
cr.loadPreset(preset);
-
- cr.setMaterial( Material.newUserMaterial(Material.Type.SURFACE,"new", 1.0));
- assertNull( cr.getPresetComponent() );
+ cr.setMaterial(Material.newMaterial(Material.Type.SURFACE, "new", 1.0, true));
+
+ assertNull(cr.getPresetComponent());
}
-
+
@Test
public void changeLineMaterialLeavesPreset() {
Parachute cr = new Parachute();
cr.loadPreset(preset);
-
- cr.setLineMaterial( Material.newUserMaterial(Material.Type.LINE,"new", 1.0));
- assertSame( preset, cr.getPresetComponent() );
+ cr.setLineMaterial(Material.newMaterial(Material.Type.LINE, "new", 1.0, true));
+
+ assertSame(preset, cr.getPresetComponent());
}
-
+
}
package net.sf.openrocket.preset;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertSame;
+import static org.junit.Assert.*;
import net.sf.openrocket.material.Material;
import net.sf.openrocket.motor.Manufacturer;
import net.sf.openrocket.rocketcomponent.Streamer;
*
*/
public class StreamerComponentTests extends BaseTestCase {
-
+
ComponentPreset preset;
@Before
public void createPreset() throws Exception {
TypedPropertyMap presetspec = new TypedPropertyMap();
presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.STREAMER);
- presetspec.put( ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
- presetspec.put( ComponentPreset.PARTNO, "partno");
- presetspec.put( ComponentPreset.LENGTH, 20.0);
- presetspec.put( ComponentPreset.WIDTH, 2.0);
- Material m = Material.newUserMaterial(Material.Type.SURFACE,"testMaterial", 2.0);
- presetspec.put( ComponentPreset.MATERIAL, m);
+ presetspec.put(ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
+ presetspec.put(ComponentPreset.PARTNO, "partno");
+ presetspec.put(ComponentPreset.LENGTH, 20.0);
+ presetspec.put(ComponentPreset.WIDTH, 2.0);
+ Material m = Material.newMaterial(Material.Type.SURFACE, "testMaterial", 2.0, true);
+ presetspec.put(ComponentPreset.MATERIAL, m);
preset = ComponentPresetFactory.create(presetspec);
}
-
+
@Test
public void testComponentType() {
Streamer cr = new Streamer();
- assertSame( ComponentPreset.Type.STREAMER, cr.getPresetType() );
+ assertSame(ComponentPreset.Type.STREAMER, cr.getPresetType());
}
@Test
cr.loadPreset(preset);
- assertEquals( 20.0, cr.getStripLength(), 0.0 );
- assertEquals( 2.0, cr.getStripWidth(), 0.0 );
- assertEquals( 2.0, cr.getLength(), 0.0 );
+ assertEquals(20.0, cr.getStripLength(), 0.0);
+ assertEquals(2.0, cr.getStripWidth(), 0.0);
+ assertEquals(2.0, cr.getLength(), 0.0);
- assertSame( preset.get( ComponentPreset.MATERIAL), cr.getMaterial() );
- assertEquals( 80.0, cr.getMass(), 0.05);
+ assertSame(preset.get(ComponentPreset.MATERIAL), cr.getMaterial());
+ assertEquals(80.0, cr.getMass(), 0.05);
}
@Test
Streamer cr = new Streamer();
cr.loadPreset(preset);
-
+
cr.setStripLength(1.0);
- assertNull( cr.getPresetComponent() );
+ assertNull(cr.getPresetComponent());
}
-
+
@Test
public void changeWidthClearsPreset() {
Streamer cr = new Streamer();
cr.loadPreset(preset);
-
+
cr.setStripWidth(1.0);
- assertNull( cr.getPresetComponent() );
+ assertNull(cr.getPresetComponent());
}
-
+
@Test
public void changeMaterialClearsPreset() {
Streamer cr = new Streamer();
cr.loadPreset(preset);
-
- cr.setMaterial( Material.newUserMaterial(Material.Type.SURFACE,"new", 1.0));
- assertNull( cr.getPresetComponent() );
+ cr.setMaterial(Material.newMaterial(Material.Type.SURFACE, "new", 1.0, true));
+
+ assertNull(cr.getPresetComponent());
}
-
+
}
package net.sf.openrocket.preset;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.*;
import net.sf.openrocket.material.Material;
import net.sf.openrocket.motor.Manufacturer;
import net.sf.openrocket.rocketcomponent.ExternalComponent.Finish;
*
*/
public class TransitionComponentTests extends BaseTestCase {
-
+
ComponentPreset preset;
@Before
public void createPreset() throws Exception {
TypedPropertyMap presetspec = new TypedPropertyMap();
presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.TRANSITION);
- presetspec.put( ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
- presetspec.put( ComponentPreset.PARTNO, "partno");
- presetspec.put( ComponentPreset.LENGTH, 2.0);
- presetspec.put( ComponentPreset.SHAPE, Transition.Shape.CONICAL);
- presetspec.put( ComponentPreset.AFT_OUTER_DIAMETER, 2.0);
- presetspec.put( ComponentPreset.FORE_OUTER_DIAMETER, 1.0);
- presetspec.put( ComponentPreset.AFT_SHOULDER_LENGTH, 1.0);
- presetspec.put( ComponentPreset.AFT_SHOULDER_DIAMETER, 1.0);
- presetspec.put( ComponentPreset.FORE_SHOULDER_LENGTH, 1.0);
- presetspec.put( ComponentPreset.FORE_SHOULDER_DIAMETER, 0.5);
- presetspec.put( ComponentPreset.FILLED, true);
- presetspec.put( ComponentPreset.MASS, 100.0);
- presetspec.put( ComponentPreset.MATERIAL, Material.newUserMaterial(Material.Type.BULK,"test", 2.0));
+ presetspec.put(ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
+ presetspec.put(ComponentPreset.PARTNO, "partno");
+ presetspec.put(ComponentPreset.LENGTH, 2.0);
+ presetspec.put(ComponentPreset.SHAPE, Transition.Shape.CONICAL);
+ presetspec.put(ComponentPreset.AFT_OUTER_DIAMETER, 2.0);
+ presetspec.put(ComponentPreset.FORE_OUTER_DIAMETER, 1.0);
+ presetspec.put(ComponentPreset.AFT_SHOULDER_LENGTH, 1.0);
+ presetspec.put(ComponentPreset.AFT_SHOULDER_DIAMETER, 1.0);
+ presetspec.put(ComponentPreset.FORE_SHOULDER_LENGTH, 1.0);
+ presetspec.put(ComponentPreset.FORE_SHOULDER_DIAMETER, 0.5);
+ presetspec.put(ComponentPreset.FILLED, true);
+ presetspec.put(ComponentPreset.MASS, 100.0);
+ presetspec.put(ComponentPreset.MATERIAL, Material.newMaterial(Material.Type.BULK, "test", 2.0, true));
preset = ComponentPresetFactory.create(presetspec);
}
-
+
@Test
public void testComponentType() {
Transition tr = new Transition();
- assertSame( ComponentPreset.Type.TRANSITION, tr.getPresetType() );
+ assertSame(ComponentPreset.Type.TRANSITION, tr.getPresetType());
}
@Test
tr.loadPreset(preset);
- assertEquals( 2.0, tr.getLength(), 0.0 );
- assertSame( Transition.Shape.CONICAL, tr.getType() );
- assertEquals( 1.0, tr.getAftRadius(), 0.0 );
- assertEquals( 1.0, tr.getForeShoulderLength(), 0.0 );
- assertEquals( 0.25, tr.getForeShoulderRadius(), 0.0 );
- assertEquals( 0.25, tr.getForeShoulderThickness(), 0.0 );
- assertEquals( 1.0, tr.getAftShoulderLength(), 0.0 );
- assertEquals( 0.5, tr.getAftShoulderRadius(), 0.0 );
- assertEquals( 0.5, tr.getAftShoulderThickness(), 0.0 );
-
- assertFalse( tr.isForeRadiusAutomatic() );
- assertFalse( tr.isAftRadiusAutomatic() );
- assertTrue( tr.isFilled() );
-
- assertSame( preset.get( ComponentPreset.MATERIAL), tr.getMaterial() );
- assertEquals( 100.0, tr.getMass(), 1.0);
+ assertEquals(2.0, tr.getLength(), 0.0);
+ assertSame(Transition.Shape.CONICAL, tr.getType());
+ assertEquals(1.0, tr.getAftRadius(), 0.0);
+ assertEquals(1.0, tr.getForeShoulderLength(), 0.0);
+ assertEquals(0.25, tr.getForeShoulderRadius(), 0.0);
+ assertEquals(0.25, tr.getForeShoulderThickness(), 0.0);
+ assertEquals(1.0, tr.getAftShoulderLength(), 0.0);
+ assertEquals(0.5, tr.getAftShoulderRadius(), 0.0);
+ assertEquals(0.5, tr.getAftShoulderThickness(), 0.0);
+
+ assertFalse(tr.isForeRadiusAutomatic());
+ assertFalse(tr.isAftRadiusAutomatic());
+ assertTrue(tr.isFilled());
+
+ assertSame(preset.get(ComponentPreset.MATERIAL), tr.getMaterial());
+ assertEquals(100.0, tr.getMass(), 1.0);
}
@Test
Transition tr = new Transition();
tr.loadPreset(preset);
-
+
tr.setLength(1.0);
- assertNull( tr.getPresetComponent() );
+ assertNull(tr.getPresetComponent());
}
-
+
@Test
public void changeAftRadiusClearsPreset() {
Transition tr = new Transition();
tr.loadPreset(preset);
-
+
tr.setAftRadius(2.0);
- assertNull( tr.getPresetComponent() );
+ assertNull(tr.getPresetComponent());
}
-
+
@Test
public void changeAftRadiusAutomaticClearsPreset() {
Transition tr = new Transition();
tr.loadPreset(preset);
-
+
tr.setAftRadiusAutomatic(true);
- assertNull( tr.getPresetComponent() );
+ assertNull(tr.getPresetComponent());
}
-
+
@Test
public void changeForeRadiusClearsPreset() {
Transition tr = new Transition();
tr.loadPreset(preset);
-
+
tr.setForeRadius(2.0);
- assertNull( tr.getPresetComponent() );
+ assertNull(tr.getPresetComponent());
}
-
+
@Test
public void changeForeRadiusAutomaticClearsPreset() {
Transition tr = new Transition();
tr.loadPreset(preset);
-
+
tr.setForeRadiusAutomatic(true);
- assertNull( tr.getPresetComponent() );
+ assertNull(tr.getPresetComponent());
}
-
+
@Test
public void changeForeShoulderRadiusClearsPreset() {
Transition tr = new Transition();
tr.loadPreset(preset);
-
+
tr.setForeShoulderRadius(2.0);
- assertNull( tr.getPresetComponent() );
+ assertNull(tr.getPresetComponent());
}
-
+
@Test
public void changeAftShoulderRadiusClearsPreset() {
Transition tr = new Transition();
tr.loadPreset(preset);
-
+
tr.setAftShoulderRadius(2.0);
- assertNull( tr.getPresetComponent() );
+ assertNull(tr.getPresetComponent());
}
-
+
@Test
public void changeAftSholderLengthLeavesPreset() {
Transition tr = new Transition();
tr.loadPreset(preset);
-
+
tr.setAftShoulderLength(2.0);
- assertSame( preset, tr.getPresetComponent() );
+ assertSame(preset, tr.getPresetComponent());
}
-
+
@Test
public void changeThicknessClearsPreset() {
Transition tr = new Transition();
tr.loadPreset(preset);
-
+
tr.setThickness(0.1);
- assertNull( tr.getPresetComponent() );
+ assertNull(tr.getPresetComponent());
}
-
-
+
+
@Test
public void changeFilledClearsPreset() {
Transition tr = new Transition();
tr.loadPreset(preset);
-
+
tr.setFilled(false);
- assertNull( tr.getPresetComponent() );
+ assertNull(tr.getPresetComponent());
}
-
+
@Test
public void changeMaterialClearsPreset() {
Transition tr = new Transition();
tr.loadPreset(preset);
-
- tr.setMaterial( Material.newUserMaterial(Material.Type.BULK,"new", 1.0));
- assertNull( tr.getPresetComponent() );
+ tr.setMaterial(Material.newMaterial(Material.Type.BULK, "new", 1.0, true));
+
+ assertNull(tr.getPresetComponent());
}
-
+
@Test
public void changeFinishLeavesPreset() {
Transition tr = new Transition();
tr.loadPreset(preset);
-
- tr.setFinish( Finish.POLISHED );
- assertSame( preset, tr.getPresetComponent() );
+ tr.setFinish(Finish.POLISHED);
+
+ assertSame(preset, tr.getPresetComponent());
}
-
+
}
*
*/
public class TransitionPresetTests extends BaseTestCase {
-
+
@Test
public void testManufacturerRequired() {
try {
TypedPropertyMap presetspec = new TypedPropertyMap();
presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.TRANSITION);
ComponentPresetFactory.create(presetspec);
- } catch ( InvalidComponentPresetException ex ) {
- PresetAssertHelper.assertInvalidPresetException( ex,
+ } catch (InvalidComponentPresetException ex) {
+ PresetAssertHelper.assertInvalidPresetException(ex,
new TypedKey<?>[] {
- ComponentPreset.MANUFACTURER,
- ComponentPreset.PARTNO,
- ComponentPreset.LENGTH,
- ComponentPreset.AFT_OUTER_DIAMETER,
- ComponentPreset.FORE_OUTER_DIAMETER
- },
- new String[] {
- "No Manufacturer specified",
- "No PartNo specified",
- "No Length specified",
- "No AftOuterDiameter specified",
- "No ForeOuterDiameter specified"
- }
+ ComponentPreset.MANUFACTURER,
+ ComponentPreset.PARTNO,
+ ComponentPreset.LENGTH,
+ ComponentPreset.AFT_OUTER_DIAMETER,
+ ComponentPreset.FORE_OUTER_DIAMETER
+ },
+ new String[] {
+ "No Manufacturer specified",
+ "No PartNo specified",
+ "No Length specified",
+ "No AftOuterDiameter specified",
+ "No ForeOuterDiameter specified"
+ }
);
}
}
-
+
@Test
public void testPartNoRequired() {
try {
TypedPropertyMap presetspec = new TypedPropertyMap();
presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.TRANSITION);
- presetspec.put( ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
+ presetspec.put(ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
ComponentPresetFactory.create(presetspec);
- } catch ( InvalidComponentPresetException ex ) {
- PresetAssertHelper.assertInvalidPresetException( ex,
+ } catch (InvalidComponentPresetException ex) {
+ PresetAssertHelper.assertInvalidPresetException(ex,
new TypedKey<?>[] {
- ComponentPreset.PARTNO,
- ComponentPreset.LENGTH,
- ComponentPreset.AFT_OUTER_DIAMETER,
- ComponentPreset.FORE_OUTER_DIAMETER
- },
- new String[] {
- "No PartNo specified",
- "No Length specified",
- "No AftOuterDiameter specified",
- "No ForeOuterDiameter specified"
- }
+ ComponentPreset.PARTNO,
+ ComponentPreset.LENGTH,
+ ComponentPreset.AFT_OUTER_DIAMETER,
+ ComponentPreset.FORE_OUTER_DIAMETER
+ },
+ new String[] {
+ "No PartNo specified",
+ "No Length specified",
+ "No AftOuterDiameter specified",
+ "No ForeOuterDiameter specified"
+ }
);
}
}
-
+
@Test
public void testLengthRequired() {
try {
TypedPropertyMap presetspec = new TypedPropertyMap();
presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.TRANSITION);
- presetspec.put( ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
- presetspec.put( ComponentPreset.PARTNO, "partno");
+ presetspec.put(ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
+ presetspec.put(ComponentPreset.PARTNO, "partno");
ComponentPresetFactory.create(presetspec);
- } catch ( InvalidComponentPresetException ex ) {
- PresetAssertHelper.assertInvalidPresetException( ex,
+ } catch (InvalidComponentPresetException ex) {
+ PresetAssertHelper.assertInvalidPresetException(ex,
new TypedKey<?>[] {
- ComponentPreset.LENGTH,
- ComponentPreset.AFT_OUTER_DIAMETER,
- ComponentPreset.FORE_OUTER_DIAMETER
- },
- new String[] {
- "No Length specified",
- "No AftOuterDiameter specified",
- "No ForeOuterDiameter specified"
- }
+ ComponentPreset.LENGTH,
+ ComponentPreset.AFT_OUTER_DIAMETER,
+ ComponentPreset.FORE_OUTER_DIAMETER
+ },
+ new String[] {
+ "No Length specified",
+ "No AftOuterDiameter specified",
+ "No ForeOuterDiameter specified"
+ }
);
}
}
-
+
@Test
public void testAftOuterDiameterRequired() {
try {
TypedPropertyMap presetspec = new TypedPropertyMap();
presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.TRANSITION);
- presetspec.put( ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
- presetspec.put( ComponentPreset.PARTNO, "partno");
- presetspec.put( ComponentPreset.LENGTH, 2.0);
- presetspec.put( ComponentPreset.SHAPE, Transition.Shape.CONICAL);
+ presetspec.put(ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
+ presetspec.put(ComponentPreset.PARTNO, "partno");
+ presetspec.put(ComponentPreset.LENGTH, 2.0);
+ presetspec.put(ComponentPreset.SHAPE, Transition.Shape.CONICAL);
ComponentPresetFactory.create(presetspec);
- } catch ( InvalidComponentPresetException ex ) {
- PresetAssertHelper.assertInvalidPresetException( ex,
+ } catch (InvalidComponentPresetException ex) {
+ PresetAssertHelper.assertInvalidPresetException(ex,
new TypedKey<?>[] {
- ComponentPreset.AFT_OUTER_DIAMETER,
- ComponentPreset.FORE_OUTER_DIAMETER
- },
- new String[] {
- "No AftOuterDiameter specified",
- "No ForeOuterDiameter specified"
- }
+ ComponentPreset.AFT_OUTER_DIAMETER,
+ ComponentPreset.FORE_OUTER_DIAMETER
+ },
+ new String[] {
+ "No AftOuterDiameter specified",
+ "No ForeOuterDiameter specified"
+ }
);
}
}
-
-
+
+
@Test
public void testForeOuterDiameterRequired() {
try {
TypedPropertyMap presetspec = new TypedPropertyMap();
presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.TRANSITION);
- presetspec.put( ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
- presetspec.put( ComponentPreset.PARTNO, "partno");
- presetspec.put( ComponentPreset.LENGTH, 2.0);
- presetspec.put( ComponentPreset.SHAPE, Transition.Shape.CONICAL);
- presetspec.put( ComponentPreset.AFT_OUTER_DIAMETER, 2.0);
+ presetspec.put(ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
+ presetspec.put(ComponentPreset.PARTNO, "partno");
+ presetspec.put(ComponentPreset.LENGTH, 2.0);
+ presetspec.put(ComponentPreset.SHAPE, Transition.Shape.CONICAL);
+ presetspec.put(ComponentPreset.AFT_OUTER_DIAMETER, 2.0);
ComponentPresetFactory.create(presetspec);
- } catch ( InvalidComponentPresetException ex ) {
- PresetAssertHelper.assertInvalidPresetException( ex,
+ } catch (InvalidComponentPresetException ex) {
+ PresetAssertHelper.assertInvalidPresetException(ex,
new TypedKey<?>[] {
ComponentPreset.FORE_OUTER_DIAMETER
- },
- new String[] {
+ },
+ new String[] {
"No ForeOuterDiameter specified"
- }
+ }
);
}
}
-
+
@Test
public void testComputeDensityNoMaterial() throws Exception {
TypedPropertyMap presetspec = new TypedPropertyMap();
presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.TRANSITION);
- presetspec.put( ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
- presetspec.put( ComponentPreset.PARTNO, "partno");
- presetspec.put( ComponentPreset.LENGTH, 2.0);
- presetspec.put( ComponentPreset.SHAPE, Transition.Shape.CONICAL);
- presetspec.put( ComponentPreset.AFT_OUTER_DIAMETER, 2.0);
- presetspec.put( ComponentPreset.FORE_OUTER_DIAMETER, 1.0);
- presetspec.put( ComponentPreset.FILLED, true);
- presetspec.put( ComponentPreset.MASS, 100.0);
+ presetspec.put(ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
+ presetspec.put(ComponentPreset.PARTNO, "partno");
+ presetspec.put(ComponentPreset.LENGTH, 2.0);
+ presetspec.put(ComponentPreset.SHAPE, Transition.Shape.CONICAL);
+ presetspec.put(ComponentPreset.AFT_OUTER_DIAMETER, 2.0);
+ presetspec.put(ComponentPreset.FORE_OUTER_DIAMETER, 1.0);
+ presetspec.put(ComponentPreset.FILLED, true);
+ presetspec.put(ComponentPreset.MASS, 100.0);
ComponentPreset preset = ComponentPresetFactory.create(presetspec);
-
+
// constants put into the presetspec above.
- double volume = /*base area*/ Math.PI * ( 1.0 * 1.0 + 1.0 * 0.5 + 0.5 * 0.5);
+ double volume = /*base area*/Math.PI * (1.0 * 1.0 + 1.0 * 0.5 + 0.5 * 0.5);
+
+ volume *= 2.0 /* times height *// 3.0; /* one third */
- volume *= 2.0 /* times height */ / 3.0; /* one third */
-
double density = 100.0 / volume;
- assertEquals("TransitionCustom",preset.get(ComponentPreset.MATERIAL).getName());
-
- assertEquals(density,preset.get(ComponentPreset.MATERIAL).getDensity(),0.01*density);
+ assertEquals("TransitionCustom", preset.get(ComponentPreset.MATERIAL).getName());
+
+ assertEquals(density, preset.get(ComponentPreset.MATERIAL).getDensity(), 0.01 * density);
}
-
+
@Test
public void testMaterial() throws Exception {
TypedPropertyMap presetspec = new TypedPropertyMap();
presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.TRANSITION);
- presetspec.put( ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
- presetspec.put( ComponentPreset.PARTNO, "partno");
- presetspec.put( ComponentPreset.LENGTH, 2.0);
- presetspec.put( ComponentPreset.SHAPE, Transition.Shape.CONICAL);
- presetspec.put( ComponentPreset.AFT_OUTER_DIAMETER, 2.0);
- presetspec.put( ComponentPreset.FORE_OUTER_DIAMETER, 1.0);
- presetspec.put( ComponentPreset.FILLED, true);
- presetspec.put( ComponentPreset.MATERIAL, Material.newUserMaterial(Material.Type.BULK,"test", 2.0));
+ presetspec.put(ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
+ presetspec.put(ComponentPreset.PARTNO, "partno");
+ presetspec.put(ComponentPreset.LENGTH, 2.0);
+ presetspec.put(ComponentPreset.SHAPE, Transition.Shape.CONICAL);
+ presetspec.put(ComponentPreset.AFT_OUTER_DIAMETER, 2.0);
+ presetspec.put(ComponentPreset.FORE_OUTER_DIAMETER, 1.0);
+ presetspec.put(ComponentPreset.FILLED, true);
+ presetspec.put(ComponentPreset.MATERIAL, Material.newMaterial(Material.Type.BULK, "test", 2.0, true));
ComponentPreset preset = ComponentPresetFactory.create(presetspec);
-
- assertEquals("test",preset.get(ComponentPreset.MATERIAL).getName());
- assertEquals(2.0,preset.get(ComponentPreset.MATERIAL).getDensity(),0.0005);
+
+ assertEquals("test", preset.get(ComponentPreset.MATERIAL).getName());
+ assertEquals(2.0, preset.get(ComponentPreset.MATERIAL).getDensity(), 0.0005);
}
-
+
@Test
public void testComputeDensityWithMaterial() throws Exception {
TypedPropertyMap presetspec = new TypedPropertyMap();
presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.TRANSITION);
- presetspec.put( ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
- presetspec.put( ComponentPreset.PARTNO, "partno");
- presetspec.put( ComponentPreset.LENGTH, 2.0);
- presetspec.put( ComponentPreset.SHAPE, Transition.Shape.CONICAL);
- presetspec.put( ComponentPreset.AFT_OUTER_DIAMETER, 2.0);
- presetspec.put( ComponentPreset.FORE_OUTER_DIAMETER, 1.0);
- presetspec.put( ComponentPreset.FILLED, true);
- presetspec.put( ComponentPreset.MASS, 100.0);
- presetspec.put( ComponentPreset.MATERIAL, Material.newUserMaterial(Material.Type.BULK,"test", 2.0));
+ presetspec.put(ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
+ presetspec.put(ComponentPreset.PARTNO, "partno");
+ presetspec.put(ComponentPreset.LENGTH, 2.0);
+ presetspec.put(ComponentPreset.SHAPE, Transition.Shape.CONICAL);
+ presetspec.put(ComponentPreset.AFT_OUTER_DIAMETER, 2.0);
+ presetspec.put(ComponentPreset.FORE_OUTER_DIAMETER, 1.0);
+ presetspec.put(ComponentPreset.FILLED, true);
+ presetspec.put(ComponentPreset.MASS, 100.0);
+ presetspec.put(ComponentPreset.MATERIAL, Material.newMaterial(Material.Type.BULK, "test", 2.0, true));
ComponentPreset preset = ComponentPresetFactory.create(presetspec);
-
+
// constants put into the presetspec above.
- double totvolume = /*base area*/ Math.PI;
+ double totvolume = /*base area*/Math.PI;
- totvolume *= 4.0 /* times height */ / 3.0; /* one third */
-
- double uppervolume = /*fore area*/ Math.PI * 0.5 * 0.5;
- uppervolume *= 2.0 /* times height */ / 3.0; /* one third */
+ totvolume *= 4.0 /* times height *// 3.0; /* one third */
+
+ double uppervolume = /*fore area*/Math.PI * 0.5 * 0.5;
+ uppervolume *= 2.0 /* times height *// 3.0; /* one third */
+
+ double volume = totvolume - uppervolume;
- double volume = totvolume-uppervolume;
-
double density = 100.0 / volume;
- assertEquals("test",preset.get(ComponentPreset.MATERIAL).getName());
-
- assertEquals(density,preset.get(ComponentPreset.MATERIAL).getDensity(),0.01*density);
+ assertEquals("test", preset.get(ComponentPreset.MATERIAL).getName());
+
+ assertEquals(density, preset.get(ComponentPreset.MATERIAL).getDensity(), 0.01 * density);
}
-
+
}
*
*/
public class TubeCouplerComponentTests extends BaseTestCase {
-
+
ComponentPreset preset;
@Before
public void createPreset() throws Exception {
TypedPropertyMap presetspec = new TypedPropertyMap();
presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.TUBE_COUPLER);
- presetspec.put( ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
- presetspec.put( ComponentPreset.PARTNO, "partno");
- presetspec.put( ComponentPreset.LENGTH, 2.0);
- presetspec.put( ComponentPreset.OUTER_DIAMETER, 2.0);
- presetspec.put( ComponentPreset.INNER_DIAMETER, 1.0);
- presetspec.put( ComponentPreset.MASS, 100.0);
+ presetspec.put(ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
+ presetspec.put(ComponentPreset.PARTNO, "partno");
+ presetspec.put(ComponentPreset.LENGTH, 2.0);
+ presetspec.put(ComponentPreset.OUTER_DIAMETER, 2.0);
+ presetspec.put(ComponentPreset.INNER_DIAMETER, 1.0);
+ presetspec.put(ComponentPreset.MASS, 100.0);
preset = ComponentPresetFactory.create(presetspec);
}
-
+
@Test
public void testComponentType() {
TubeCoupler tc = new TubeCoupler();
- assertSame( ComponentPreset.Type.TUBE_COUPLER, tc.getPresetType() );
+ assertSame(ComponentPreset.Type.TUBE_COUPLER, tc.getPresetType());
}
@Test
tc.loadPreset(preset);
- assertEquals( 2.0, tc.getLength(), 0.0 );
- assertEquals( 1.0, tc.getOuterRadius(), 0.0 );
- assertEquals( 0.5, tc.getInnerRadius(), 0.0 );
+ assertEquals(2.0, tc.getLength(), 0.0);
+ assertEquals(1.0, tc.getOuterRadius(), 0.0);
+ assertEquals(0.5, tc.getInnerRadius(), 0.0);
- assertFalse( tc.isInnerRadiusAutomatic() );
- assertFalse( tc.isOuterRadiusAutomatic() );
+ assertFalse(tc.isInnerRadiusAutomatic());
+ assertFalse(tc.isOuterRadiusAutomatic());
- assertSame( preset.get( ComponentPreset.MATERIAL), tc.getMaterial() );
- assertEquals( 100.0, tc.getMass(), 0.05);
+ assertSame(preset.get(ComponentPreset.MATERIAL), tc.getMaterial());
+ assertEquals(100.0, tc.getMass(), 0.05);
}
@Test
TubeCoupler tc = new TubeCoupler();
tc.loadPreset(preset);
-
+
tc.setLength(1.0);
- assertSame( preset, tc.getPresetComponent() );
+ assertSame(preset, tc.getPresetComponent());
}
-
+
@Test
public void changeODClearsPreset() {
TubeCoupler tc = new TubeCoupler();
tc.loadPreset(preset);
-
+
tc.setOuterRadius(2.0);
- assertNull( tc.getPresetComponent() );
+ assertNull(tc.getPresetComponent());
}
-
+
@Test
public void changeIDClearsPreset() {
TubeCoupler tc = new TubeCoupler();
tc.loadPreset(preset);
-
+
tc.setInnerRadius(0.75);
- assertNull( tc.getPresetComponent() );
+ assertNull(tc.getPresetComponent());
}
-
+
@Test
public void changeThicknessClearsPreset() {
TubeCoupler tc = new TubeCoupler();
tc.loadPreset(preset);
-
+
tc.setThickness(0.1);
- assertNull( tc.getPresetComponent() );
+ assertNull(tc.getPresetComponent());
}
-
+
@Test
public void changeMaterialClearsPreset() {
TubeCoupler tc = new TubeCoupler();
tc.loadPreset(preset);
-
- tc.setMaterial( Material.newUserMaterial(Material.Type.BULK,"new", 1.0));
- assertNull( tc.getPresetComponent() );
+ tc.setMaterial(Material.newMaterial(Material.Type.BULK, "new", 1.0, true));
+
+ assertNull(tc.getPresetComponent());
}
-
+
}
*
*/
public class TubeCouplerPresetTests {
-
+
@Test
public void testManufacturerRequired() {
try {
TypedPropertyMap presetspec = new TypedPropertyMap();
presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.TUBE_COUPLER);
ComponentPresetFactory.create(presetspec);
- } catch ( InvalidComponentPresetException ex ) {
- PresetAssertHelper.assertInvalidPresetException( ex,
+ } catch (InvalidComponentPresetException ex) {
+ PresetAssertHelper.assertInvalidPresetException(ex,
new TypedKey<?>[] {
- ComponentPreset.MANUFACTURER,
- ComponentPreset.PARTNO,
- ComponentPreset.LENGTH
- },
- new String[] {
- "No Manufacturer specified",
- "No PartNo specified",
- "No Length specified",
- "Preset dimensions underspecified"
- }
+ ComponentPreset.MANUFACTURER,
+ ComponentPreset.PARTNO,
+ ComponentPreset.LENGTH
+ },
+ new String[] {
+ "No Manufacturer specified",
+ "No PartNo specified",
+ "No Length specified",
+ "Preset dimensions underspecified"
+ }
);
}
}
-
+
@Test
public void testPartNoRequired() {
try {
TypedPropertyMap presetspec = new TypedPropertyMap();
presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.TUBE_COUPLER);
- presetspec.put( ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
+ presetspec.put(ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
ComponentPresetFactory.create(presetspec);
- } catch ( InvalidComponentPresetException ex ) {
- PresetAssertHelper.assertInvalidPresetException( ex,
+ } catch (InvalidComponentPresetException ex) {
+ PresetAssertHelper.assertInvalidPresetException(ex,
new TypedKey<?>[] {
- ComponentPreset.PARTNO,
- ComponentPreset.LENGTH
- },
- new String[] {
- "No PartNo specified",
- "No Length specified",
- "Preset dimensions underspecified"
- }
+ ComponentPreset.PARTNO,
+ ComponentPreset.LENGTH
+ },
+ new String[] {
+ "No PartNo specified",
+ "No Length specified",
+ "Preset dimensions underspecified"
+ }
);
}
}
-
+
@Test
public void testLengthRequired() {
try {
TypedPropertyMap presetspec = new TypedPropertyMap();
presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.TUBE_COUPLER);
- presetspec.put( ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
- presetspec.put( ComponentPreset.PARTNO, "partno");
+ presetspec.put(ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
+ presetspec.put(ComponentPreset.PARTNO, "partno");
ComponentPresetFactory.create(presetspec);
- } catch ( InvalidComponentPresetException ex ) {
- PresetAssertHelper.assertInvalidPresetException( ex,
+ } catch (InvalidComponentPresetException ex) {
+ PresetAssertHelper.assertInvalidPresetException(ex,
new TypedKey<?>[] {
ComponentPreset.LENGTH
- },
- new String[] {
- "No Length specified",
- "Preset dimensions underspecified"
- }
+ },
+ new String[] {
+ "No Length specified",
+ "Preset dimensions underspecified"
+ }
);
}
}
-
+
@Test
public void testOnlyOuterDiameter() {
try {
TypedPropertyMap presetspec = new TypedPropertyMap();
presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.TUBE_COUPLER);
- presetspec.put( ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
- presetspec.put( ComponentPreset.PARTNO, "partno");
- presetspec.put( ComponentPreset.LENGTH, 2.0);
- presetspec.put( ComponentPreset.OUTER_DIAMETER, 2.0);
+ presetspec.put(ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
+ presetspec.put(ComponentPreset.PARTNO, "partno");
+ presetspec.put(ComponentPreset.LENGTH, 2.0);
+ presetspec.put(ComponentPreset.OUTER_DIAMETER, 2.0);
ComponentPresetFactory.create(presetspec);
- } catch ( InvalidComponentPresetException ex ) {
- PresetAssertHelper.assertInvalidPresetException( ex,
+ } catch (InvalidComponentPresetException ex) {
+ PresetAssertHelper.assertInvalidPresetException(ex,
null,
- new String[] {
+ new String[] {
"Preset dimensions underspecified"
- }
+ }
);
}
}
-
+
@Test
public void testOnlyInnerDiameter() {
try {
TypedPropertyMap presetspec = new TypedPropertyMap();
presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.TUBE_COUPLER);
- presetspec.put( ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
- presetspec.put( ComponentPreset.PARTNO, "partno");
- presetspec.put( ComponentPreset.LENGTH, 2.0);
- presetspec.put( ComponentPreset.INNER_DIAMETER, 2.0);
+ presetspec.put(ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
+ presetspec.put(ComponentPreset.PARTNO, "partno");
+ presetspec.put(ComponentPreset.LENGTH, 2.0);
+ presetspec.put(ComponentPreset.INNER_DIAMETER, 2.0);
ComponentPresetFactory.create(presetspec);
- } catch ( InvalidComponentPresetException ex ) {
- PresetAssertHelper.assertInvalidPresetException( ex,
+ } catch (InvalidComponentPresetException ex) {
+ PresetAssertHelper.assertInvalidPresetException(ex,
null,
- new String[] {
+ new String[] {
"Preset dimensions underspecified"
- }
+ }
);
}
}
-
+
@Test
public void testOnlyThicknessDiameter() {
try {
TypedPropertyMap presetspec = new TypedPropertyMap();
presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.TUBE_COUPLER);
- presetspec.put( ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
- presetspec.put( ComponentPreset.PARTNO, "partno");
- presetspec.put( ComponentPreset.LENGTH, 2.0);
- presetspec.put( ComponentPreset.THICKNESS, 2.0);
+ presetspec.put(ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
+ presetspec.put(ComponentPreset.PARTNO, "partno");
+ presetspec.put(ComponentPreset.LENGTH, 2.0);
+ presetspec.put(ComponentPreset.THICKNESS, 2.0);
ComponentPresetFactory.create(presetspec);
- } catch ( InvalidComponentPresetException ex ) {
- PresetAssertHelper.assertInvalidPresetException( ex,
+ } catch (InvalidComponentPresetException ex) {
+ PresetAssertHelper.assertInvalidPresetException(ex,
null,
- new String[] {
+ new String[] {
"Preset dimensions underspecified"
- }
+ }
);
}
}
-
+
@Test
public void testComputeInnerDiameter() throws Exception {
TypedPropertyMap presetspec = new TypedPropertyMap();
presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.TUBE_COUPLER);
- presetspec.put( ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
- presetspec.put( ComponentPreset.PARTNO, "partno");
- presetspec.put( ComponentPreset.LENGTH, 2.0);
- presetspec.put( ComponentPreset.OUTER_DIAMETER, 2.0);
- presetspec.put( ComponentPreset.THICKNESS, 0.5);
+ presetspec.put(ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
+ presetspec.put(ComponentPreset.PARTNO, "partno");
+ presetspec.put(ComponentPreset.LENGTH, 2.0);
+ presetspec.put(ComponentPreset.OUTER_DIAMETER, 2.0);
+ presetspec.put(ComponentPreset.THICKNESS, 0.5);
ComponentPreset preset = ComponentPresetFactory.create(presetspec);
-
- assertEquals(1.0,preset.get(ComponentPreset.INNER_DIAMETER).doubleValue(),0.0);
+
+ assertEquals(1.0, preset.get(ComponentPreset.INNER_DIAMETER).doubleValue(), 0.0);
}
-
+
@Test
public void testComputeOuterDiameter() throws Exception {
TypedPropertyMap presetspec = new TypedPropertyMap();
presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.TUBE_COUPLER);
- presetspec.put( ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
- presetspec.put( ComponentPreset.PARTNO, "partno");
- presetspec.put( ComponentPreset.LENGTH, 2.0);
- presetspec.put( ComponentPreset.INNER_DIAMETER, 1.0);
- presetspec.put( ComponentPreset.THICKNESS, 0.5);
+ presetspec.put(ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
+ presetspec.put(ComponentPreset.PARTNO, "partno");
+ presetspec.put(ComponentPreset.LENGTH, 2.0);
+ presetspec.put(ComponentPreset.INNER_DIAMETER, 1.0);
+ presetspec.put(ComponentPreset.THICKNESS, 0.5);
ComponentPreset preset = ComponentPresetFactory.create(presetspec);
-
- assertEquals(2.0,preset.get(ComponentPreset.OUTER_DIAMETER).doubleValue(),0.0);
+
+ assertEquals(2.0, preset.get(ComponentPreset.OUTER_DIAMETER).doubleValue(), 0.0);
}
-
+
@Test
public void testComputeThickness() throws Exception {
TypedPropertyMap presetspec = new TypedPropertyMap();
presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.TUBE_COUPLER);
- presetspec.put( ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
- presetspec.put( ComponentPreset.PARTNO, "partno");
- presetspec.put( ComponentPreset.LENGTH, 2.0);
- presetspec.put( ComponentPreset.OUTER_DIAMETER, 2.0);
- presetspec.put( ComponentPreset.INNER_DIAMETER, 1.0);
+ presetspec.put(ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
+ presetspec.put(ComponentPreset.PARTNO, "partno");
+ presetspec.put(ComponentPreset.LENGTH, 2.0);
+ presetspec.put(ComponentPreset.OUTER_DIAMETER, 2.0);
+ presetspec.put(ComponentPreset.INNER_DIAMETER, 1.0);
ComponentPreset preset = ComponentPresetFactory.create(presetspec);
-
- assertEquals(0.5,preset.get(ComponentPreset.THICKNESS).doubleValue(),0.0);
+
+ assertEquals(0.5, preset.get(ComponentPreset.THICKNESS).doubleValue(), 0.0);
}
-
+
@Test
public void testComputeThicknessLooses() throws Exception {
// If all OUTER_DIAMETER, INNER_DIAMETER and THICKNESS are
// specified, THICKNESS is recomputed.
TypedPropertyMap presetspec = new TypedPropertyMap();
presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.TUBE_COUPLER);
- presetspec.put( ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
- presetspec.put( ComponentPreset.PARTNO, "partno");
- presetspec.put( ComponentPreset.LENGTH, 2.0);
- presetspec.put( ComponentPreset.OUTER_DIAMETER, 2.0);
- presetspec.put( ComponentPreset.INNER_DIAMETER, 1.0);
- presetspec.put( ComponentPreset.THICKNESS, 15.0);
+ presetspec.put(ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
+ presetspec.put(ComponentPreset.PARTNO, "partno");
+ presetspec.put(ComponentPreset.LENGTH, 2.0);
+ presetspec.put(ComponentPreset.OUTER_DIAMETER, 2.0);
+ presetspec.put(ComponentPreset.INNER_DIAMETER, 1.0);
+ presetspec.put(ComponentPreset.THICKNESS, 15.0);
ComponentPreset preset = ComponentPresetFactory.create(presetspec);
-
- assertEquals(0.5,preset.get(ComponentPreset.THICKNESS).doubleValue(),0.0);
+
+ assertEquals(0.5, preset.get(ComponentPreset.THICKNESS).doubleValue(), 0.0);
}
-
+
@Test
public void testComputeDensityNoMaterial() throws Exception {
TypedPropertyMap presetspec = new TypedPropertyMap();
presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.TUBE_COUPLER);
- presetspec.put( ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
- presetspec.put( ComponentPreset.PARTNO, "partno");
- presetspec.put( ComponentPreset.LENGTH, 2.0);
- presetspec.put( ComponentPreset.OUTER_DIAMETER, 2.0);
- presetspec.put( ComponentPreset.INNER_DIAMETER, 1.0);
- presetspec.put( ComponentPreset.MASS, 100.0);
+ presetspec.put(ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
+ presetspec.put(ComponentPreset.PARTNO, "partno");
+ presetspec.put(ComponentPreset.LENGTH, 2.0);
+ presetspec.put(ComponentPreset.OUTER_DIAMETER, 2.0);
+ presetspec.put(ComponentPreset.INNER_DIAMETER, 1.0);
+ presetspec.put(ComponentPreset.MASS, 100.0);
ComponentPreset preset = ComponentPresetFactory.create(presetspec);
-
+
// Compute the volume by hand here using a slightly different formula from
// the real implementation. The magic numbers are based on the
// constants put into the presetspec above.
- double volume = /*outer area*/ (Math.PI * 1.0) - /* inner area */ (Math.PI * .25);
+ double volume = /*outer area*/(Math.PI * 1.0) - /* inner area */(Math.PI * .25);
volume *= 2.0; /* times length */
double density = 100.0 / volume;
- assertEquals("TubeCustom",preset.get(ComponentPreset.MATERIAL).getName());
- assertEquals(density,preset.get(ComponentPreset.MATERIAL).getDensity(),0.0005);
+ assertEquals("TubeCustom", preset.get(ComponentPreset.MATERIAL).getName());
+ assertEquals(density, preset.get(ComponentPreset.MATERIAL).getDensity(), 0.0005);
}
-
+
@Test
public void testMaterial() throws Exception {
TypedPropertyMap presetspec = new TypedPropertyMap();
presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.TUBE_COUPLER);
- presetspec.put( ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
- presetspec.put( ComponentPreset.PARTNO, "partno");
- presetspec.put( ComponentPreset.LENGTH, 2.0);
- presetspec.put( ComponentPreset.OUTER_DIAMETER, 2.0);
- presetspec.put( ComponentPreset.INNER_DIAMETER, 1.0);
- presetspec.put( ComponentPreset.MATERIAL, Material.newUserMaterial(Material.Type.BULK,"test", 2.0));
+ presetspec.put(ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
+ presetspec.put(ComponentPreset.PARTNO, "partno");
+ presetspec.put(ComponentPreset.LENGTH, 2.0);
+ presetspec.put(ComponentPreset.OUTER_DIAMETER, 2.0);
+ presetspec.put(ComponentPreset.INNER_DIAMETER, 1.0);
+ presetspec.put(ComponentPreset.MATERIAL, Material.newMaterial(Material.Type.BULK, "test", 2.0, true));
ComponentPreset preset = ComponentPresetFactory.create(presetspec);
-
- assertEquals("test",preset.get(ComponentPreset.MATERIAL).getName());
- assertEquals(2.0,preset.get(ComponentPreset.MATERIAL).getDensity(),0.0005);
+
+ assertEquals("test", preset.get(ComponentPreset.MATERIAL).getName());
+ assertEquals(2.0, preset.get(ComponentPreset.MATERIAL).getDensity(), 0.0005);
}
-
+
@Test
public void testComputeDensityWithMaterial() throws Exception {
TypedPropertyMap presetspec = new TypedPropertyMap();
presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.TUBE_COUPLER);
- presetspec.put( ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
- presetspec.put( ComponentPreset.PARTNO, "partno");
- presetspec.put( ComponentPreset.LENGTH, 2.0);
- presetspec.put( ComponentPreset.OUTER_DIAMETER, 2.0);
- presetspec.put( ComponentPreset.INNER_DIAMETER, 1.0);
- presetspec.put( ComponentPreset.MASS, 100.0);
- presetspec.put( ComponentPreset.MATERIAL, Material.newUserMaterial(Material.Type.BULK,"test", 2.0));
+ presetspec.put(ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
+ presetspec.put(ComponentPreset.PARTNO, "partno");
+ presetspec.put(ComponentPreset.LENGTH, 2.0);
+ presetspec.put(ComponentPreset.OUTER_DIAMETER, 2.0);
+ presetspec.put(ComponentPreset.INNER_DIAMETER, 1.0);
+ presetspec.put(ComponentPreset.MASS, 100.0);
+ presetspec.put(ComponentPreset.MATERIAL, Material.newMaterial(Material.Type.BULK, "test", 2.0, true));
ComponentPreset preset = ComponentPresetFactory.create(presetspec);
-
+
// Compute the volume by hand here using a slightly different formula from
// the real implementation. The magic numbers are based on the
// constants put into the presetspec above.
- double volume = /*outer area*/ (Math.PI * 1.0) - /* inner area */ (Math.PI * .25);
+ double volume = /*outer area*/(Math.PI * 1.0) - /* inner area */(Math.PI * .25);
volume *= 2.0; /* times length */
double density = 100.0 / volume;
- assertEquals("test",preset.get(ComponentPreset.MATERIAL).getName());
- assertEquals(density,preset.get(ComponentPreset.MATERIAL).getDensity(),0.0005);
+ assertEquals("test", preset.get(ComponentPreset.MATERIAL).getName());
+ assertEquals(density, preset.get(ComponentPreset.MATERIAL).getDensity(), 0.0005);
}
-
+
}
package net.sf.openrocket.rocketcomponent;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.*;
import java.awt.Color;
public class FinSetTest extends BaseTestCase {
-
+
@Test
public void testFreeformConvert() {
testFreeformConvert(new TrapezoidFinSet());
private void testFreeformConvert(FinSet fin) {
FreeformFinSet converted;
- Material mat = Material.newUserMaterial(Type.BULK, "foo", 0.1);
+ Material mat = Material.newMaterial(Type.BULK, "foo", 0.1, true);
fin.setBaseRotation(1.1);
fin.setCantAngle(0.001);
fin.setTabShift(0.015);
fin.setThickness(0.005);
-
+
converted = FreeformFinSet.convertFinSet((FinSet) fin.copy());
ComponentCompare.assertSimilarity(fin, converted, true);
assertEquals(converted.getComponentName(), converted.getName());
-
+
// Create test rocket
Rocket rocket = new Rocket();
Stage stage = new Stage();
assertTrue(l1.changed);
assertEquals(ComponentChangeEvent.NONFUNCTIONAL_CHANGE, l1.changetype);
-
+
// Create copy
RocketComponent rocketcopy = rocket.copy();
import org.junit.Test;
public class SymmetricComponentVolumeTest extends BaseTestCase {
-
+
@Test
public void simpleConeFilled() {
NoseCone nc = new NoseCone();
nc.setLength(1.0);
nc.setFilled(true);
- nc.setType( Transition.Shape.CONICAL );
+ nc.setType(Transition.Shape.CONICAL);
nc.setAftRadius(1.0);
- nc.setMaterial( Material.newUserMaterial(Material.Type.BULK,"test",density));
-
+ nc.setMaterial(Material.newMaterial(Material.Type.BULK, "test", density, true));
+
Coordinate cg = nc.getCG();
-
- System.out.println( nc.getComponentVolume() + "\t" + nc.getMass());
- System.out.println( cg );
+
+ System.out.println(nc.getComponentVolume() + "\t" + nc.getMass());
+ System.out.println(cg);
double volume = Math.PI / 3.0;
double mass = density * volume;
- System.out.println( volume );
+ System.out.println(volume);
- assertEquals( volume, nc.getComponentVolume(), epsilonPercent * volume);
- assertEquals( mass, nc.getMass(), epsilonPercent * mass );
+ assertEquals(volume, nc.getComponentVolume(), epsilonPercent * volume);
+ assertEquals(mass, nc.getMass(), epsilonPercent * mass);
- assertEquals( 0.75, cg.x, epsilonPercent * 0.75 );
- assertEquals( mass, cg.weight, epsilonPercent * mass);
+ assertEquals(0.75, cg.x, epsilonPercent * 0.75);
+ assertEquals(mass, cg.weight, epsilonPercent * mass);
}
-
+
@Test
public void simpleConeWithShoulderFilled() {
NoseCone nc = new NoseCone();
final double epsilonPercent = 0.001;
final double density = 2.0;
-
+
nc.setLength(1.0);
nc.setFilled(true);
- nc.setType( Transition.Shape.CONICAL );
+ nc.setType(Transition.Shape.CONICAL);
nc.setAftRadius(1.0);
nc.setAftShoulderRadius(1.0);
nc.setAftShoulderLength(1.0);
nc.setAftShoulderThickness(1.0);
- nc.setMaterial( Material.newUserMaterial(Material.Type.BULK,"test",density));
-
+ nc.setMaterial(Material.newMaterial(Material.Type.BULK, "test", density, true));
+
Coordinate cg = nc.getCG();
-
- System.out.println( nc.getComponentVolume() + "\t" + nc.getMass());
- System.out.println( cg );
-
+
+ System.out.println(nc.getComponentVolume() + "\t" + nc.getMass());
+ System.out.println(cg);
+
double volume = Math.PI / 3.0;
volume += Math.PI;
-
+
double mass = density * volume;
-
- System.out.println( volume + "\t" + mass );
-
- assertEquals( volume, nc.getComponentVolume(), epsilonPercent * volume);
- assertEquals( mass, nc.getMass(), epsilonPercent * mass );
- assertEquals( 1.312, cg.x, epsilonPercent * 1.071 );
- assertEquals( mass, cg.weight, epsilonPercent * mass);
+ System.out.println(volume + "\t" + mass);
+
+ assertEquals(volume, nc.getComponentVolume(), epsilonPercent * volume);
+ assertEquals(mass, nc.getMass(), epsilonPercent * mass);
+
+ assertEquals(1.312, cg.x, epsilonPercent * 1.071);
+ assertEquals(mass, cg.weight, epsilonPercent * mass);
}
-
+
@Test
public void simpleConeHollow() {
NoseCone nc = new NoseCone();
nc.setLength(1.0);
nc.setAftRadius(1.0);
nc.setThickness(0.5);
- nc.setType( Transition.Shape.CONICAL );
- nc.setMaterial( Material.newUserMaterial(Material.Type.BULK,"test",density));
+ nc.setType(Transition.Shape.CONICAL);
+ nc.setMaterial(Material.newMaterial(Material.Type.BULK, "test", density, true));
Coordinate cg = nc.getCG();
-
- System.out.println( nc.getComponentVolume() + "\t" + nc.getMass());
- System.out.println( cg );
-
- double volume = Math.PI / 3.0; // outer volume
+
+ System.out.println(nc.getComponentVolume() + "\t" + nc.getMass());
+ System.out.println(cg);
+
+ double volume = Math.PI / 3.0; // outer volume
// manually projected Thickness of 0.5 on to radius to determine
// the innerConeDimen. Since the outer cone is "square" (height = radius),
double innerConeDimen = 1.0 - Math.sqrt(2.0) / 2.0;
double innerVolume = Math.PI / 3.0 * innerConeDimen * innerConeDimen * innerConeDimen;
volume -= innerVolume;
-
+
double mass = density * volume;
-
- System.out.println( volume );
- assertEquals( volume, nc.getComponentVolume(), epsilonPercent * volume);
- assertEquals( mass, nc.getMass(), epsilonPercent * mass );
+ System.out.println(volume);
- assertEquals( 0.7454, cg.x, epsilonPercent * 0.7454 );
- assertEquals( mass, cg.weight, epsilonPercent * mass);
+ assertEquals(volume, nc.getComponentVolume(), epsilonPercent * volume);
+ assertEquals(mass, nc.getMass(), epsilonPercent * mass);
+
+ assertEquals(0.7454, cg.x, epsilonPercent * 0.7454);
+ assertEquals(mass, cg.weight, epsilonPercent * mass);
}
-
+
@Test
public void simpleConeWithShoulderHollow() {
NoseCone nc = new NoseCone();
final double epsilonPercent = 0.001;
final double density = 2.0;
-
+
nc.setLength(1.0);
- nc.setType( Transition.Shape.CONICAL );
+ nc.setType(Transition.Shape.CONICAL);
nc.setAftRadius(1.0);
nc.setThickness(0.5);
nc.setAftShoulderRadius(1.0);
nc.setAftShoulderLength(1.0);
nc.setAftShoulderThickness(0.5);
- nc.setMaterial( Material.newUserMaterial(Material.Type.BULK,"test",density));
-
+ nc.setMaterial(Material.newMaterial(Material.Type.BULK, "test", density, true));
+
Coordinate cg = nc.getCG();
-
- System.out.println( nc.getComponentVolume() + "\t" + nc.getMass());
- System.out.println( cg );
-
- double volume = Math.PI / 3.0; // outer volume
-
+
+ System.out.println(nc.getComponentVolume() + "\t" + nc.getMass());
+ System.out.println(cg);
+
+ double volume = Math.PI / 3.0; // outer volume
+
// manually projected Thickness of 0.5 on to radius to determine
// the innerConeDimen. Since the outer cone is "square" (height = radius),
// we only need to compute this one dimension in order to compute the
double innerConeDimen = 1.0 - Math.sqrt(2.0) / 2.0;
double innerVolume = Math.PI / 3.0 * innerConeDimen * innerConeDimen * innerConeDimen;
volume -= innerVolume;
-
- volume += Math.PI - Math.PI * 0.5 * 0.5;
-
+
+ volume += Math.PI - Math.PI * 0.5 * 0.5;
+
double mass = density * volume;
-
- System.out.println( volume );
- assertEquals( volume, nc.getComponentVolume(), epsilonPercent * volume);
- assertEquals( mass, nc.getMass(), epsilonPercent * mass );
+ System.out.println(volume);
+
+ assertEquals(volume, nc.getComponentVolume(), epsilonPercent * volume);
+ assertEquals(mass, nc.getMass(), epsilonPercent * mass);
- assertEquals( 1.2719, cg.x, epsilonPercent * 1.2719 );
- assertEquals( mass, cg.weight, epsilonPercent * mass);
+ assertEquals(1.2719, cg.x, epsilonPercent * 1.2719);
+ assertEquals(mass, cg.weight, epsilonPercent * mass);
}
-
+
@Test
public void simpleTransitionFilled() {
Transition nc = new Transition();
final double epsilonPercent = 0.001;
final double density = 2.0;
-
+
nc.setLength(4.0);
nc.setFilled(true);
- nc.setType( Transition.Shape.CONICAL );
+ nc.setType(Transition.Shape.CONICAL);
nc.setForeRadius(1.0);
nc.setAftRadius(2.0);
- nc.setMaterial( Material.newUserMaterial(Material.Type.BULK,"test",density));
+ nc.setMaterial(Material.newMaterial(Material.Type.BULK, "test", density, true));
Coordinate cg = nc.getCG();
-
- System.out.println( nc.getComponentVolume() + "\t" + nc.getMass());
- System.out.println( cg );
-
- double volume = Math.PI / 3.0 * (2.0*2.0 + 2.0 * 1.0 + 1.0 * 1.0) * 4.0;
- double mass = density * volume;
+ System.out.println(nc.getComponentVolume() + "\t" + nc.getMass());
+ System.out.println(cg);
- System.out.println( volume );
+ double volume = Math.PI / 3.0 * (2.0 * 2.0 + 2.0 * 1.0 + 1.0 * 1.0) * 4.0;
- assertEquals( volume, nc.getComponentVolume(), epsilonPercent * volume);
- assertEquals( mass, nc.getMass(), epsilonPercent * mass );
+ double mass = density * volume;
- assertEquals( 2.4285, cg.x, epsilonPercent * 2.4285 );
- assertEquals( mass, cg.weight, epsilonPercent * mass);
+ System.out.println(volume);
+
+ assertEquals(volume, nc.getComponentVolume(), epsilonPercent * volume);
+ assertEquals(mass, nc.getMass(), epsilonPercent * mass);
+
+ assertEquals(2.4285, cg.x, epsilonPercent * 2.4285);
+ assertEquals(mass, cg.weight, epsilonPercent * mass);
}
-
+
@Test
public void simpleTransitionWithShouldersFilled() {
Transition nc = new Transition();
final double epsilonPercent = 0.001;
final double density = 2.0;
-
+
nc.setLength(4.0);
nc.setFilled(true);
- nc.setType( Transition.Shape.CONICAL );
+ nc.setType(Transition.Shape.CONICAL);
nc.setForeRadius(1.0);
nc.setAftRadius(2.0);
nc.setAftShoulderLength(1.0);
nc.setForeShoulderLength(1.0);
nc.setForeShoulderRadius(1.0);
nc.setForeShoulderThickness(1.0);
- nc.setMaterial( Material.newUserMaterial(Material.Type.BULK,"test",density));
+ nc.setMaterial(Material.newMaterial(Material.Type.BULK, "test", density, true));
Coordinate cg = nc.getCG();
-
- System.out.println( nc.getComponentVolume() + "\t" + nc.getMass());
- System.out.println( cg );
-
- double volume = Math.PI / 3.0 * (2.0*2.0 + 2.0 * 1.0 + 1.0 * 1.0) * 4.0;
+
+ System.out.println(nc.getComponentVolume() + "\t" + nc.getMass());
+ System.out.println(cg);
+
+ double volume = Math.PI / 3.0 * (2.0 * 2.0 + 2.0 * 1.0 + 1.0 * 1.0) * 4.0;
// plus aft shoulder:
volume += Math.PI * 1.0 * 2.0 * 2.0;
// plus fore shoulder:
volume += Math.PI * 1.0 * 1.0 * 1.0;
- double mass = density * volume;
+ double mass = density * volume;
- System.out.println( volume );
+ System.out.println(volume);
- assertEquals( volume, nc.getComponentVolume(), epsilonPercent * volume);
- assertEquals( mass, nc.getMass(), epsilonPercent * mass );
+ assertEquals(volume, nc.getComponentVolume(), epsilonPercent * volume);
+ assertEquals(mass, nc.getMass(), epsilonPercent * mass);
- assertEquals( 2.8023, cg.x, epsilonPercent * 2.8023 );
- assertEquals( mass, cg.weight, epsilonPercent * mass);
+ assertEquals(2.8023, cg.x, epsilonPercent * 2.8023);
+ assertEquals(mass, cg.weight, epsilonPercent * mass);
}
-
+
@Test
public void simpleTransitionHollow1() {
Transition nc = new Transition();
final double epsilonPercent = 0.001;
final double density = 2.0;
-
+
nc.setLength(1.0);
- nc.setType( Transition.Shape.CONICAL );
+ nc.setType(Transition.Shape.CONICAL);
nc.setForeRadius(0.5);
nc.setAftRadius(1.0);
nc.setThickness(0.5);
- nc.setMaterial( Material.newUserMaterial(Material.Type.BULK,"test",density));
+ nc.setMaterial(Material.newMaterial(Material.Type.BULK, "test", density, true));
Coordinate cg = nc.getCG();
-
- System.out.println( nc.getComponentVolume() + "\t" + nc.getMass());
- System.out.println( cg );
-
+
+ System.out.println(nc.getComponentVolume() + "\t" + nc.getMass());
+ System.out.println(cg);
+
// Volume of filled transition =
- double filledVolume = Math.PI /3.0 * ( 1.0*1.0 + 1.0 * 0.5 + 0.5 * 0.5 ) * 1.0;
-
+ double filledVolume = Math.PI / 3.0 * (1.0 * 1.0 + 1.0 * 0.5 + 0.5 * 0.5) * 1.0;
+
// magic 2D cad drawing...
//
// Since the thickness >= fore radius, the
double innerConeRadius = 0.441;
double innerConeLength = 0.882;
- double innerVolume = Math.PI /3.0 * innerConeLength * innerConeRadius * innerConeRadius;
+ double innerVolume = Math.PI / 3.0 * innerConeLength * innerConeRadius * innerConeRadius;
double volume = filledVolume - innerVolume;
- double mass = density * volume;
+ double mass = density * volume;
- System.out.println( volume );
+ System.out.println(volume);
- assertEquals( volume, nc.getComponentVolume(), epsilonPercent * volume);
- assertEquals( mass, nc.getMass(), epsilonPercent * mass );
+ assertEquals(volume, nc.getComponentVolume(), epsilonPercent * volume);
+ assertEquals(mass, nc.getMass(), epsilonPercent * mass);
- assertEquals( 0.5884, cg.x, epsilonPercent * 0.5884 );
- assertEquals( mass, cg.weight, epsilonPercent * mass);
+ assertEquals(0.5884, cg.x, epsilonPercent * 0.5884);
+ assertEquals(mass, cg.weight, epsilonPercent * mass);
}
-
+
@Test
public void simpleTransitionWithShouldersHollow1() {
Transition nc = new Transition();
final double epsilonPercent = 0.001;
final double density = 2.0;
-
+
nc.setLength(1.0);
- nc.setType( Transition.Shape.CONICAL );
+ nc.setType(Transition.Shape.CONICAL);
nc.setForeRadius(0.5);
nc.setAftRadius(1.0);
nc.setThickness(0.5);
nc.setAftShoulderThickness(0.5);
nc.setForeShoulderLength(1.0);
nc.setForeShoulderRadius(0.5);
- nc.setForeShoulderThickness(0.5); // note this means fore shoulder is filled.
- nc.setMaterial( Material.newUserMaterial(Material.Type.BULK,"test",density));
+ nc.setForeShoulderThickness(0.5); // note this means fore shoulder is filled.
+ nc.setMaterial(Material.newMaterial(Material.Type.BULK, "test", density, true));
Coordinate cg = nc.getCG();
-
- System.out.println( nc.getComponentVolume() + "\t" + nc.getMass());
- System.out.println( cg );
-
+
+ System.out.println(nc.getComponentVolume() + "\t" + nc.getMass());
+ System.out.println(cg);
+
// Volume of filled transition =
- double filledVolume = Math.PI /3.0 * ( 1.0*1.0 + 1.0 * 0.5 + 0.5 * 0.5 ) * 1.0;
-
+ double filledVolume = Math.PI / 3.0 * (1.0 * 1.0 + 1.0 * 0.5 + 0.5 * 0.5) * 1.0;
+
// magic 2D cad drawing...
//
// Since the thickness >= fore radius, the
double innerConeRadius = 0.441;
double innerConeLength = 0.882;
- double innerVolume = Math.PI /3.0 * innerConeLength * innerConeRadius * innerConeRadius;
+ double innerVolume = Math.PI / 3.0 * innerConeLength * innerConeRadius * innerConeRadius;
double volume = filledVolume - innerVolume;
// Now add fore shoulder
volume += Math.PI * 1.0 * 0.5 * 0.5;
- double mass = density * volume;
+ double mass = density * volume;
- System.out.println( volume );
+ System.out.println(volume);
- assertEquals( volume, nc.getComponentVolume(), epsilonPercent * volume);
- assertEquals( mass, nc.getMass(), epsilonPercent * mass );
+ assertEquals(volume, nc.getComponentVolume(), epsilonPercent * volume);
+ assertEquals(mass, nc.getMass(), epsilonPercent * mass);
- assertEquals( 0.8581, cg.x, epsilonPercent * 0.8581 );
- assertEquals( mass, cg.weight, epsilonPercent * mass);
+ assertEquals(0.8581, cg.x, epsilonPercent * 0.8581);
+ assertEquals(mass, cg.weight, epsilonPercent * mass);
}
-
+
@Test
public void simpleTransitionHollow2() {
Transition nc = new Transition();
final double epsilonPercent = 0.001;
final double density = 2.0;
-
+
nc.setLength(1.0);
- nc.setType( Transition.Shape.CONICAL );
+ nc.setType(Transition.Shape.CONICAL);
nc.setForeRadius(0.5);
nc.setAftRadius(1.0);
nc.setThickness(0.25);
- nc.setMaterial( Material.newUserMaterial(Material.Type.BULK,"test",density));
+ nc.setMaterial(Material.newMaterial(Material.Type.BULK, "test", density, true));
Coordinate cg = nc.getCG();
-
- System.out.println( nc.getComponentVolume() + "\t" + nc.getMass());
- System.out.println( cg );
-
+
+ System.out.println(nc.getComponentVolume() + "\t" + nc.getMass());
+ System.out.println(cg);
+
// Volume of filled transition =
- double filledVolume = Math.PI /3.0 * ( 1.0*1.0 + 1.0 * 0.5 + 0.5 * 0.5 ) * 1.0;
-
+ double filledVolume = Math.PI / 3.0 * (1.0 * 1.0 + 1.0 * 0.5 + 0.5 * 0.5) * 1.0;
+
// magic 2D cad drawing...
//
// Since the thickness < fore radius, the
double innerTransitionAftRadius = 0.7205;
double innerTransitionForeRadius = 0.2205;
- double innerVolume = Math.PI /3.0 * ( innerTransitionAftRadius * innerTransitionAftRadius + innerTransitionAftRadius * innerTransitionForeRadius + innerTransitionForeRadius * innerTransitionForeRadius);
+ double innerVolume = Math.PI / 3.0
+ * (innerTransitionAftRadius * innerTransitionAftRadius + innerTransitionAftRadius * innerTransitionForeRadius + innerTransitionForeRadius * innerTransitionForeRadius);
double volume = filledVolume - innerVolume;
- double mass = density * volume;
+ double mass = density * volume;
- System.out.println( volume );
+ System.out.println(volume);
- assertEquals( volume, nc.getComponentVolume(), epsilonPercent * volume);
- assertEquals( mass, nc.getMass(), epsilonPercent * mass );
+ assertEquals(volume, nc.getComponentVolume(), epsilonPercent * volume);
+ assertEquals(mass, nc.getMass(), epsilonPercent * mass);
- assertEquals( 0.56827, cg.x, epsilonPercent * 0.56827 );
- assertEquals( mass, cg.weight, epsilonPercent * mass);
+ assertEquals(0.56827, cg.x, epsilonPercent * 0.56827);
+ assertEquals(mass, cg.weight, epsilonPercent * mass);
}
-
+
@Test
public void simpleTransitionWithShouldersHollow2() {
Transition nc = new Transition();
final double epsilonPercent = 0.001;
final double density = 2.0;
-
+
nc.setLength(1.0);
- nc.setType( Transition.Shape.CONICAL );
+ nc.setType(Transition.Shape.CONICAL);
nc.setForeRadius(0.5);
nc.setAftRadius(1.0);
nc.setThickness(0.25);
nc.setForeShoulderRadius(0.5);
nc.setForeShoulderThickness(0.25);
- nc.setMaterial( Material.newUserMaterial(Material.Type.BULK,"test",density));
+ nc.setMaterial(Material.newMaterial(Material.Type.BULK, "test", density, true));
Coordinate cg = nc.getCG();
-
- System.out.println( nc.getComponentVolume() + "\t" + nc.getMass());
- System.out.println( cg );
-
+
+ System.out.println(nc.getComponentVolume() + "\t" + nc.getMass());
+ System.out.println(cg);
+
// Volume of filled transition =
- double filledVolume = Math.PI /3.0 * ( 1.0*1.0 + 1.0 * 0.5 + 0.5 * 0.5 ) * 1.0;
-
+ double filledVolume = Math.PI / 3.0 * (1.0 * 1.0 + 1.0 * 0.5 + 0.5 * 0.5) * 1.0;
+
// magic 2D cad drawing...
//
// Since the thickness < fore radius, the
double innerTransitionAftRadius = 0.7205;
double innerTransitionForeRadius = 0.2205;
- double innerVolume = Math.PI /3.0 * ( innerTransitionAftRadius * innerTransitionAftRadius + innerTransitionAftRadius * innerTransitionForeRadius + innerTransitionForeRadius * innerTransitionForeRadius);
+ double innerVolume = Math.PI / 3.0
+ * (innerTransitionAftRadius * innerTransitionAftRadius + innerTransitionAftRadius * innerTransitionForeRadius + innerTransitionForeRadius * innerTransitionForeRadius);
double volume = filledVolume - innerVolume;
volume += Math.PI * 1.0 * 0.5 * 0.5 - Math.PI * 1.0 * 0.25 * 0.25;
- double mass = density * volume;
+ double mass = density * volume;
- System.out.println( volume );
+ System.out.println(volume);
- assertEquals( volume, nc.getComponentVolume(), epsilonPercent * volume);
- assertEquals( mass, nc.getMass(), epsilonPercent * mass );
+ assertEquals(volume, nc.getComponentVolume(), epsilonPercent * volume);
+ assertEquals(mass, nc.getMass(), epsilonPercent * mass);
- assertEquals( 0.7829, cg.x, epsilonPercent * 0.7829 );
- assertEquals( mass, cg.weight, epsilonPercent * mass);
+ assertEquals(0.7829, cg.x, epsilonPercent * 0.7829);
+ assertEquals(mass, cg.weight, epsilonPercent * mass);
}
-
+
}