package net.miginfocom.layout;

import java.util.HashMap;

public final class PlatformDefaults {
   private static int DEF_H_UNIT = 1;
   private static int DEF_V_UNIT = 2;
   private static InCellGapProvider GAP_PROVIDER = null;
   private static volatile int MOD_COUNT = 0;
   private static final UnitValue LPX4 = new UnitValue(4.0F, 1, (String)null);
   private static final UnitValue LPX6 = new UnitValue(6.0F, 1, (String)null);
   private static final UnitValue LPX7 = new UnitValue(7.0F, 1, (String)null);
   private static final UnitValue LPX9 = new UnitValue(9.0F, 1, (String)null);
   private static final UnitValue LPX10 = new UnitValue(10.0F, 1, (String)null);
   private static final UnitValue LPX11 = new UnitValue(11.0F, 1, (String)null);
   private static final UnitValue LPX12 = new UnitValue(12.0F, 1, (String)null);
   private static final UnitValue LPX14 = new UnitValue(14.0F, 1, (String)null);
   private static final UnitValue LPX16 = new UnitValue(16.0F, 1, (String)null);
   private static final UnitValue LPX18 = new UnitValue(18.0F, 1, (String)null);
   private static final UnitValue LPX20 = new UnitValue(20.0F, 1, (String)null);
   private static final UnitValue LPY4 = new UnitValue(4.0F, 2, (String)null);
   private static final UnitValue LPY6 = new UnitValue(6.0F, 2, (String)null);
   private static final UnitValue LPY7 = new UnitValue(7.0F, 2, (String)null);
   private static final UnitValue LPY9 = new UnitValue(9.0F, 2, (String)null);
   private static final UnitValue LPY10 = new UnitValue(10.0F, 2, (String)null);
   private static final UnitValue LPY11 = new UnitValue(11.0F, 2, (String)null);
   private static final UnitValue LPY12 = new UnitValue(12.0F, 2, (String)null);
   private static final UnitValue LPY14 = new UnitValue(14.0F, 2, (String)null);
   private static final UnitValue LPY16 = new UnitValue(16.0F, 2, (String)null);
   private static final UnitValue LPY18 = new UnitValue(18.0F, 2, (String)null);
   private static final UnitValue LPY20 = new UnitValue(20.0F, 2, (String)null);
   public static final int WINDOWS_XP = 0;
   public static final int MAC_OSX = 1;
   public static final int GNOME = 2;
   private static int CUR_PLAF = 0;
   private static final UnitValue[] PANEL_INS = new UnitValue[4];
   private static final UnitValue[] DIALOG_INS = new UnitValue[4];
   private static String BUTTON_FORMAT = null;
   private static final HashMap<String, UnitValue> HOR_DEFS = new HashMap(32);
   private static final HashMap<String, UnitValue> VER_DEFS = new HashMap(32);
   private static BoundSize DEF_VGAP = null;
   private static BoundSize DEF_HGAP = null;
   static BoundSize RELATED_X = null;
   static BoundSize RELATED_Y = null;
   static BoundSize UNRELATED_X = null;
   static BoundSize UNRELATED_Y = null;
   private static UnitValue BUTT_WIDTH = null;
   private static Float horScale = null;
   private static Float verScale = null;
   public static final int BASE_FONT_SIZE = 100;
   public static final int BASE_SCALE_FACTOR = 101;
   public static final int BASE_REAL_PIXEL = 102;
   private static int LP_BASE = 101;
   private static Integer BASE_DPI_FORCED = null;
   private static int BASE_DPI = 96;
   private static boolean dra = true;

   public static int getCurrentPlatform() {
      String var0 = System.getProperty("os.name");
      if (var0.startsWith("Mac OS")) {
         return 1;
      } else {
         return var0.startsWith("Linux") ? 2 : 0;
      }
   }

   private PlatformDefaults() {
   }

   public static void setPlatform(int var0) {
      switch(var0) {
      case 0:
         setRelatedGap(LPX4, LPY4);
         setUnrelatedGap(LPX7, LPY9);
         setParagraphGap(LPX14, LPY14);
         setIndentGap(LPX9, LPY9);
         setGridCellGap(LPX4, LPY4);
         setMinimumButtonWidth(new UnitValue(75.0F, 1, (String)null));
         setButtonOrder("L_E+U+YNBXOCAH_R");
         setDialogInsets(LPY11, LPX11, LPY11, LPX11);
         setPanelInsets(LPY7, LPX7, LPY7, LPX7);
         break;
      case 1:
         setRelatedGap(LPX4, LPY4);
         setUnrelatedGap(LPX7, LPY9);
         setParagraphGap(LPX14, LPY14);
         setIndentGap(LPX10, LPY10);
         setGridCellGap(LPX4, LPY4);
         setMinimumButtonWidth(new UnitValue(68.0F, 1, (String)null));
         setButtonOrder("L_HE+U+NYBXCOA_R");
         setDialogInsets(LPY14, LPX20, LPY20, LPX20);
         setPanelInsets(LPY16, LPX16, LPY16, LPX16);
         break;
      case 2:
         setRelatedGap(LPX6, LPY6);
         setUnrelatedGap(LPX12, LPY12);
         setParagraphGap(LPX18, LPY18);
         setIndentGap(LPX12, LPY12);
         setGridCellGap(LPX6, LPY6);
         setMinimumButtonWidth(new UnitValue(85.0F, 1, (String)null));
         setButtonOrder("L_HE+UNYACBXIO_R");
         setDialogInsets(LPY12, LPX12, LPY12, LPX12);
         setPanelInsets(LPY6, LPX6, LPY6, LPX6);
         break;
      default:
         throw new IllegalArgumentException("Unknown platform: " + var0);
      }

      CUR_PLAF = var0;
      BASE_DPI = BASE_DPI_FORCED != null ? BASE_DPI_FORCED : getPlatformDPI(var0);
   }

   private static int getPlatformDPI(int var0) {
      switch(var0) {
      case 0:
      case 2:
         return 96;
      case 1:
         try {
            return System.getProperty("java.version").compareTo("1.6") < 0 ? 72 : 96;
         } catch (Throwable var2) {
            return 72;
         }
      default:
         throw new IllegalArgumentException("Unknown platform: " + var0);
      }
   }

   public static int getPlatform() {
      return CUR_PLAF;
   }

   public static int getDefaultDPI() {
      return BASE_DPI;
   }

   public static void setDefaultDPI(Integer var0) {
      BASE_DPI = var0 != null ? var0 : getPlatformDPI(CUR_PLAF);
      BASE_DPI_FORCED = var0;
   }

   public static Float getHorizontalScaleFactor() {
      return horScale;
   }

   public static void setHorizontalScaleFactor(Float var0) {
      if (!LayoutUtil.equals(horScale, var0)) {
         horScale = var0;
         ++MOD_COUNT;
      }

   }

   public static Float getVerticalScaleFactor() {
      return verScale;
   }

   public static void setVerticalScaleFactor(Float var0) {
      if (!LayoutUtil.equals(verScale, var0)) {
         verScale = var0;
         ++MOD_COUNT;
      }

   }

   public static int getLogicalPixelBase() {
      return LP_BASE;
   }

   public static void setLogicalPixelBase(int var0) {
      if (LP_BASE != var0) {
         if (var0 < 100 || var0 > 101) {
            throw new IllegalArgumentException("Unrecognized base: " + var0);
         }

         LP_BASE = var0;
         ++MOD_COUNT;
      }

   }

   public static void setRelatedGap(UnitValue var0, UnitValue var1) {
      setUnitValue(new String[]{"r", "rel", "related"}, var0, var1);
      RELATED_X = new BoundSize(var0, var0, (UnitValue)null, "rel:rel");
      RELATED_Y = new BoundSize(var1, var1, (UnitValue)null, "rel:rel");
   }

   public static void setUnrelatedGap(UnitValue var0, UnitValue var1) {
      setUnitValue(new String[]{"u", "unrel", "unrelated"}, var0, var1);
      UNRELATED_X = new BoundSize(var0, var0, (UnitValue)null, "unrel:unrel");
      UNRELATED_Y = new BoundSize(var1, var1, (UnitValue)null, "unrel:unrel");
   }

   public static void setParagraphGap(UnitValue var0, UnitValue var1) {
      setUnitValue(new String[]{"p", "para", "paragraph"}, var0, var1);
   }

   public static void setIndentGap(UnitValue var0, UnitValue var1) {
      setUnitValue(new String[]{"i", "ind", "indent"}, var0, var1);
   }

   public static void setGridCellGap(UnitValue var0, UnitValue var1) {
      if (var0 != null) {
         DEF_HGAP = new BoundSize(var0, var0, (UnitValue)null, (String)null);
      }

      if (var1 != null) {
         DEF_VGAP = new BoundSize(var1, var1, (UnitValue)null, (String)null);
      }

      ++MOD_COUNT;
   }

   public static void setMinimumButtonWidth(UnitValue var0) {
      BUTT_WIDTH = var0;
      ++MOD_COUNT;
   }

   public static UnitValue getMinimumButtonWidth() {
      return BUTT_WIDTH;
   }

   public static UnitValue getUnitValueX(String var0) {
      return (UnitValue)HOR_DEFS.get(var0);
   }

   public static UnitValue getUnitValueY(String var0) {
      return (UnitValue)VER_DEFS.get(var0);
   }

   public static final void setUnitValue(String[] var0, UnitValue var1, UnitValue var2) {
      String[] var3 = var0;
      int var4 = var0.length;

      for(int var5 = 0; var5 < var4; ++var5) {
         String var6 = var3[var5];
         String var7 = var6.toLowerCase().trim();
         if (var1 != null) {
            HOR_DEFS.put(var7, var1);
         }

         if (var2 != null) {
            VER_DEFS.put(var7, var2);
         }
      }

      ++MOD_COUNT;
   }

   static int convertToPixels(float var0, String var1, boolean var2, float var3, ContainerWrapper var4, ComponentWrapper var5) {
      UnitValue var6 = (UnitValue)(var2 ? HOR_DEFS : VER_DEFS).get(var1);
      return var6 != null ? Math.round(var0 * (float)var6.getPixels(var3, var4, var5)) : -87654312;
   }

   public static String getButtonOrder() {
      return BUTTON_FORMAT;
   }

   public static void setButtonOrder(String var0) {
      BUTTON_FORMAT = var0;
      ++MOD_COUNT;
   }

   static String getTagForChar(char var0) {
      switch(var0) {
      case 'a':
         return "apply";
      case 'b':
         return "back";
      case 'c':
         return "cancel";
      case 'd':
      case 'f':
      case 'g':
      case 'j':
      case 'k':
      case 'm':
      case 'p':
      case 'q':
      case 's':
      case 't':
      case 'v':
      case 'w':
      default:
         return null;
      case 'e':
         return "help2";
      case 'h':
         return "help";
      case 'i':
         return "finish";
      case 'l':
         return "left";
      case 'n':
         return "no";
      case 'o':
         return "ok";
      case 'r':
         return "right";
      case 'u':
         return "other";
      case 'x':
         return "next";
      case 'y':
         return "yes";
      }
   }

   public static BoundSize getGridGapX() {
      return DEF_HGAP;
   }

   public static BoundSize getGridGapY() {
      return DEF_VGAP;
   }

   public static UnitValue getDialogInsets(int var0) {
      return DIALOG_INS[var0];
   }

   public static void setDialogInsets(UnitValue var0, UnitValue var1, UnitValue var2, UnitValue var3) {
      if (var0 != null) {
         DIALOG_INS[0] = var0;
      }

      if (var1 != null) {
         DIALOG_INS[1] = var1;
      }

      if (var2 != null) {
         DIALOG_INS[2] = var2;
      }

      if (var3 != null) {
         DIALOG_INS[3] = var3;
      }

      ++MOD_COUNT;
   }

   public static UnitValue getPanelInsets(int var0) {
      return PANEL_INS[var0];
   }

   public static void setPanelInsets(UnitValue var0, UnitValue var1, UnitValue var2, UnitValue var3) {
      if (var0 != null) {
         PANEL_INS[0] = var0;
      }

      if (var1 != null) {
         PANEL_INS[1] = var1;
      }

      if (var2 != null) {
         PANEL_INS[2] = var2;
      }

      if (var3 != null) {
         PANEL_INS[3] = var3;
      }

      ++MOD_COUNT;
   }

   public static float getLabelAlignPercentage() {
      return CUR_PLAF == 1 ? 1.0F : 0.0F;
   }

   static BoundSize getDefaultComponentGap(ComponentWrapper var0, ComponentWrapper var1, int var2, String var3, boolean var4) {
      if (GAP_PROVIDER != null) {
         return GAP_PROVIDER.getDefaultGap(var0, var1, var2, var3, var4);
      } else if (var1 == null) {
         return null;
      } else {
         return var2 != 2 && var2 != 4 ? RELATED_Y : RELATED_X;
      }
   }

   public static InCellGapProvider getGapProvider() {
      return GAP_PROVIDER;
   }

   public static void setGapProvider(InCellGapProvider var0) {
      GAP_PROVIDER = var0;
   }

   public static int getModCount() {
      return MOD_COUNT;
   }

   public void invalidate() {
      ++MOD_COUNT;
   }

   public static int getDefaultHorizontalUnit() {
      return DEF_H_UNIT;
   }

   public static void setDefaultHorizontalUnit(int var0) {
      if (var0 >= 0 && var0 <= 27) {
         if (DEF_H_UNIT != var0) {
            DEF_H_UNIT = var0;
            ++MOD_COUNT;
         }

      } else {
         throw new IllegalArgumentException("Illegal Unit: " + var0);
      }
   }

   public static int getDefaultVerticalUnit() {
      return DEF_V_UNIT;
   }

   public static void setDefaultVerticalUnit(int var0) {
      if (var0 >= 0 && var0 <= 27) {
         if (DEF_V_UNIT != var0) {
            DEF_V_UNIT = var0;
            ++MOD_COUNT;
         }

      } else {
         throw new IllegalArgumentException("Illegal Unit: " + var0);
      }
   }

   public static boolean getDefaultRowAlignmentBaseline() {
      return dra;
   }

   public static void setDefaultRowAlignmentBaseline(boolean var0) {
      dra = var0;
   }

   static {
      setPlatform(getCurrentPlatform());
      MOD_COUNT = 0;
   }
}
